todo-43.2-remove-legacy-event-consumption.md 2.9 KB

Todo 43.2 Remove Legacy Event Consumption Plan

Status: done

Result

  • Removed legacy event acceptance from Runtime and EventAgent production consumers.
  • Added wrong-source negative coverage.
  • Added a real chat-client [DONE] integration test for compatible providers without finish_reason.
  • Focused tests pass (77 passed) and the full suite passes (82 passed, one existing warning).

Goal

Enforce typed event-source isolation at production consumer boundaries so the legacy compatibility constructor cannot silently mask incorrect ChatAgent or EventAgent wiring.

Scope

  • Runtime accepts only text_event from ChatAgent streams.
  • EventAgent accepts only provider_tool_call from its provider-tools argument request.
  • Remaining runtime/WebSocket test fixtures use the correct typed constructor.
  • Add negative tests for wrong-source events.
  • Add one chat-client SSE integration test proving [DONE] flush emits one provider tool call when no finish reason is present.
  • Keep the legacy constructor temporarily for unrelated external callers, but production consumers must not accept it.

Files

  • Modify: src/agent_lab/application/runtime.py
  • Modify: src/agent_lab/application/event_agent.py
  • Modify: tests/test_debug_runtime.py
  • Modify: tests/test_event_agent.py
  • Modify: tests/test_websocket_api.py

Plan

Plan

  1. Replace remaining production-path legacy fixtures with typed constructors.
  2. Add negative tests that wrong-source and legacy events do not cross the consumer boundaries.
  3. Add a MockTransport/SSE [DONE] integration test for the real chat client.
  4. Verify RED failures expose the three legacy consumer branches.
  5. Remove legacy consumption from Runtime/EventAgent and run all regressions.

Act

  • Runtime tests: emit provider_tool_call and legacy event from the ChatAgent fake and assert no tool handoff occurs; keep the positive text_event test.
  • EventAgent tests: emit text_event/legacy event from its provider fake and assert it falls back rather than treating either as resolved provider arguments; keep the positive provider call test.
  • WebSocket/client tests: replace legacy fixtures with typed constructors and add SSE chunks with provider tool calls, no finish_reason, then [DONE]; assert exactly one provider_tool_call.
  • Run focused tests and confirm expected failure before production changes.
  • Remove event from consumer condition sets.
  • Re-run focused and full tests.

Observe

Confirm typed-source isolation is enforced by negative tests and that no remaining production-path fixture relies on StreamItem.event(...).

Update

  • Mark 43, 43.1, and 43.2 done only after renewed spec and quality review.
  • Commit separately with the masked-regression risk in the message.

Verification

  • uv run pytest tests/test_debug_runtime.py tests/test_event_agent.py tests/test_websocket_api.py tests/test_openai_stream_parser.py -q
  • uv run pytest
  • git diff --check