todo-27-event-agent-tool-arguments.md 1.5 KB

Todo 27: EventAgent Tool Arguments

Status

done

Goal

Stop EventAgent turns from ending with event agent did not return arguments for mock_search when the compatible provider fails to return a tool call in the exact shape the parser expects.

Root Cause

EventAgent currently sends one tool schema to the LLM and expects the stream parser to emit a provider tool-call event. There are two brittle points:

  • The OpenAI-compatible request includes tools but does not force the single tool through tool_choice.
  • The stream parser only drains accumulated provider tool calls when finish_reason == "tool_calls", so providers that end with another terminal reason can drop the accumulated tool call.

If neither path emits an event, EventAgent raises a ValueError and the tool result becomes a handler error.

Scope

  • Force the single supplied tool in OpenAI-compatible requests.
  • Drain accumulated provider tool calls on any terminal finish reason.
  • Add an EventAgent fallback to registry/context argument resolution when the LLM returns no tool call.
  • Keep ChatAgent tool-free.

Verification

  • Failing parser test for terminal finish_reason="stop" with accumulated tool call.
  • Failing OpenAI client payload test for tool_choice.
  • Failing EventAgent test for no-tool-call fallback.
  • uv run pytest tests/test_openai_stream_parser.py tests/test_event_agent.py tests/test_websocket_api.py::test_openai_chat_client_streams_sse_chunks_through_parser -q passes: 9 tests.
  • uv run pytest passes: 53 tests.