todo-22-text-event-protocol.md 2.1 KB

Todo 22 Text Event Protocol Plan

Status: done

Goal

Remove ChatAgent dependence on provider tool_calls, parse event names from streamed text, and fix Agent config buttons that could stop responding after stale script/HTML mismatches.

Why

The target architecture keeps ChatAgent focused on fast user-facing replies. EventAgent extends external capability after ChatAgent names the needed events. Provider tool-call payloads force ChatAgent to know tool-call mechanics and can delay or complicate streaming.

Scope

  • Parse a small text protocol from delta.content: visible text streams to the UI, while names inside <agent_events>...</agent_events> become internal ToolCallEvent values.
  • Stop passing tools to ChatAgent and stop adding assistant tool_calls or tool role replies to ChatAgent history.
  • Insert a generated system message listing enabled event names and descriptions for each ChatAgent round that can still request events.
  • Keep EventAgent tool results visible to the UI and pass only one aggregate EventAgent results user message back to ChatAgent.
  • Version the static JS URL and guard click binding so missing/old buttons do not abort initialization.

Verification

  • Parser test proves text events are extracted from streamed content and hidden from displayed message deltas.
  • Runtime tests prove ChatAgent receives no tools, no tool_calls, no tool history, and does receive the event catalog system message plus aggregate EventAgent summary.
  • Static tests prove the app script is versioned and Agent config buttons use guarded click binding.
  • uv run pytest passed: 50 tests, 1 existing Starlette deprecation warning.
  • Local browser check confirmed one ChatAgent button, one EventAgent button, versioned app.js, and both dialogs open on click.

Result

  • Added streamed text event parsing around <agent_events>.
  • Replaced ChatAgent tool schemas with a generated event catalog system message.
  • Preserved EventAgent execution and UI tool-result visibility while simplifying ChatAgent history.
  • Fixed the practical button failure mode caused by stale or mismatched static JS.