You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit df828c0
Browse filesBrowse the repository at this point in the historyBrowse files
Stop false stale-send guard after tool-call turns (#2115)
## Description
The chat send guard falsely blocked the next message with "New messages
loaded — please review before sending" on essentially every turn after
the first — sending twice was needed each time. It surfaced first on a
tool-call turn, but the root cause affects every agent response.
## Root cause
A2A marks per-message `contextId`/`taskId` as optional — the `Task` is
the canonical carrier, so persisted history messages routinely store
them as empty strings. After a turn completes the UI keeps the
locally-streamed message copies (it does not reload from the backend),
and those carry the task's real `contextId`/`taskId`, so the send guard
keys them as `["task", contextId, taskId, contentSignature]`. The
backend-extracted copies, with empty ids, fall back to `["message",
<id>]` instead — and for converted tool messages that id is even
regenerated (`uuidv4`) on every extraction. So a persisted agent message
never matches its locally-streamed counterpart, the guard counts the
backend as ahead of the local view, and blocks the send. Every turn has
an agent response, so every send after the first tripped it.
## Fix
Carry `contextId`/`taskId` on agent messages so the streamed and
persisted copies key identically. Two layers:
- **UI** (`ui/src/lib/messageHandlers.ts`): when flattening
`task.history`, backfill `contextId`/`taskId` from the task for
**every** extracted agent message (text and tool), treating `""` as
absent (`||`, not `??`). This is the complete fix on its own — it
repairs already-persisted sessions and works regardless of which runtime
produced them.
- **Runtime** (source, defense-in-depth, helps new sessions): stamp
`contextId`/`taskId` onto agent messages at emission time, in both
producers — Python `kagent-adk` (`convert_event_to_a2a_message`) and the
Go ADK executor, now the default declarative runtime
(`go/adk/pkg/a2a/executor.go`, via a `newAgentStatusEvent` seam). A2A
allows omission, and remote agents are out of our control, so the UI
backfill stays regardless.
Scope is limited to agent messages; user messages are keyed by
`messageId` and already match.
## Reproduction
<img width="402" height="301" alt="image (7)"
src="https://github.com/user-attachments/assets/136d194d-c195-4ba7-8319-9fc729a5a59d"
/>
1. Send a message that triggers a tool call.
2. Send another message → blocked by the stale-send banner with no
actual change.
---------
Signed-off-by: Jeremy Alvis <[email protected]>
0 commit comments