fix(acp): parse session/update content as ContentBlock, not string
The ACP spec defines session/update content as a ContentBlock object
({type, text}) but we decoded it as a string. This dropped every
agent_message_chunk and left prompt responses empty. E2E against the
real opencode acp binary surfaced the bug.
- internal/acp/messages.go: add ContentBlock struct; Update.Content is
now ContentBlock.
- internal/acp/client.go: handleNotification extracts Text when
Content.Type == "text"; other types are logged at debug and dropped.
- internal/acp/client_test.go: NDJSON framing test sends content as a
ContentBlock object and reads .Text.
- README.md: document /acp/* routes + CODESPACE_OPENCODE_ARGS env.
Verified end-to-end: POST /acp/prompt returns text="Hi there!", 4
messages in history (1 user + 3 agent chunks), 0 invalid session/update
log entries.
Conversation: 019f357d-4236-7010-949c-e61067618d42
This commit is contained in:
+10
-2
@@ -237,9 +237,17 @@ func (c *Client) handleNotification(method string, params json.RawMessage) {
|
||||
}
|
||||
switch up.Update.SessionUpdate {
|
||||
case "agent_message_chunk":
|
||||
c.history.Add("agent", up.Update.Content)
|
||||
if up.Update.Content.Type == "text" {
|
||||
c.history.Add("agent", up.Update.Content.Text)
|
||||
} else {
|
||||
c.lg.Debug("acp drop non-text agent chunk", "workspace_id", c.workspaceID, "type", up.Update.Content.Type)
|
||||
}
|
||||
case "user_message_chunk":
|
||||
c.history.Add("user", up.Update.Content)
|
||||
if up.Update.Content.Type == "text" {
|
||||
c.history.Add("user", up.Update.Content.Text)
|
||||
} else {
|
||||
c.lg.Debug("acp drop non-text user chunk", "workspace_id", c.workspaceID, "type", up.Update.Content.Type)
|
||||
}
|
||||
default:
|
||||
c.lg.Debug("acp drop update", "workspace_id", c.workspaceID, "type", up.Update.SessionUpdate)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user