Files
multica/server/pkg
Eve be121ef759 fix(agent): make cursor stream protocol drift loud instead of silent (MUL-5434)
#6071 reports Cursor tasks that demonstrably read files, ran commands and
called the Multica CLI, yet showed a single blob of agent text with no
reasoning and no tool rows. The run still reported success and tools=0.

`switch evt.Type` in cursor.go had no `default` branch, so any top-level
event type we do not handle was dropped with no counter and no warning.
Renaming only the top-level types of a healthy stream
(`thinking`->`reasoning`, `tool_call`->`tool_calls`), leaving every nested
field untouched, reproduces the report exactly: status=completed, output =
the result text alone, tool_use=0, thinking=0, zero diagnostics. The
existing unknown-subtype warning cannot catch this — it only increments
once the type has already matched — so "no unknown-subtype warning" does
not rule out protocol drift.

Two diagnostic gaps are closed:

- Add the `default` branch with a bounded, content-free tally of unhandled
  top-level types, reported once per run as a warning and alongside
  tool_use_count in the protocol summary. Type names are normalized through
  observedCursorEventType and distinct names are capped at 16 plus an
  overflow bucket, so a hostile or noisy stream cannot grow the map or leak
  payload into logs. `user` (the CLI echoing our prompt, present in every
  recorded run) is explicitly benign so the warning does not fire always.
- Count assistant text separately from the terminal result text. The result
  event writes into the same builder, so last_assistant_bytes equalled
  result_bytes even when the assistant streamed nothing — erasing the
  signal that says "only the final answer arrived". This also aligns cursor
  with claude, which already reports assistant bytes only.

Unrecognized events are still never coerced into tool or reasoning
messages; guessing at upstream additions is the failure mode MUL-5231
already fixed once. This is diagnosis only and does not itself restore the
missing tool rows — identifying which upstream shape changed requires a
captured 2026.07.23 stream, and this warning is what makes that
identifiable from a single production log line.

Co-authored-by: multica-agent <github@multica.ai>
2026-07-29 14:28:02 +08:00
..