Skip to content

Expose Codex agent message phases in ACP chunks#267

Merged
Rizzen merged 1 commit into
agentclientprotocol:mainfrom
nikita-ashihmin:codex/agent-message-phase-meta
Jul 8, 2026
Merged

Expose Codex agent message phases in ACP chunks#267
Rizzen merged 1 commit into
agentclientprotocol:mainfrom
nikita-ashihmin:codex/agent-message-phase-meta

Conversation

@nikita-ashihmin

@nikita-ashihmin nikita-ashihmin commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add Codex message phase metadata under _meta.codex.phase for streamed agent_message_chunk updates
  • preserve phase metadata when replaying thread history and response-item fallback history
  • add coverage for commentary vs final_answer message chunks and fallback phase preservation

Wire Format Example

Before this change, visible assistant text and mid-turn commentary both arrived as the same ACP block type with no phase metadata. A client could see that this was an agent_message_chunk, but could not tell whether it should be rendered inside a Working/Worked group or as the final answer:

{
  "sessionUpdate": "agent_message_chunk",
  "messageId": "commentary-message",
  "content": {
    "type": "text",
    "text": "Checking the relevant event mapping."
  }
}

After this change, the block type is still the standard ACP agent_message_chunk, but Codex-specific phase metadata is attached under _meta.codex.phase:

{
  "sessionUpdate": "agent_message_chunk",
  "messageId": "commentary-message",
  "content": {
    "type": "text",
    "text": "Checking the relevant event mapping."
  },
  "_meta": {
    "codex": {
      "phase": "commentary"
    }
  }
}

Final answer text uses the same ACP block type, with phase: "final_answer":

{
  "sessionUpdate": "agent_message_chunk",
  "messageId": "final-message",
  "content": {
    "type": "text",
    "text": "Yes, here is the answer."
  },
  "_meta": {
    "codex": {
      "phase": "final_answer"
    }
  }
}

This lets clients keep compatibility with ACP while routing commentary chunks into a Working/Worked group and final_answer chunks into the visible assistant answer.

Tests

  • npm test -- src/__tests__/CodexACPAgent/agent-message-events.test.ts src/__tests__/CodexACPAgent/response-item-history-fallback.test.ts
  • npm run typecheck
  • npm test

@Rizzen
Rizzen merged commit 843a504 into agentclientprotocol:main Jul 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants