Skip to content

feat(acp): implement Agent Communication Protocol (ACP) server and context-aware tool execution - #5

Merged
mrazza merged 23 commits into
mainfrom
feat/acp
Jul 26, 2026
Merged

feat(acp): implement Agent Communication Protocol (ACP) server and context-aware tool execution#5
mrazza merged 23 commits into
mainfrom
feat/acp

Conversation

@mrazza

@mrazza mrazza commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

This PR implements the initial Agent Communication Protocol (ACP) server specification over JSON-RPC 2.0. It enables client applications to communicate with coma as an agent service over stdio/JSON-RPC, managing agent sessions, executing turns, and streaming thought and message content back to clients in real-time.

Additionally, this PR refactors core agent types to align with ACP session semantics (AgentSession) and introduces support for context-aware tool execution.

@oca-agent oca-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Overall, this is a solid implementation. Refactoring Agent -> Session clarifies the codebase architecture (distinguishing the overall agent application/service from an individual context window session), and the new acp module is clean, well-structured, and thoroughly tested. The compile-time enum string mapping (session_new <-> session/new) is particularly slick with zero runtime allocation overhead.

Below are inline comments highlighting a panic hazard, error handling edge cases, and protocol robustness suggestions to help guide the implementation before taking this out of draft.

Comment thread src/acp/Server.zig Outdated
Comment thread src/agent/Tool.zig Outdated
Comment thread src/acp/Server.zig
Comment thread src/acp/json_rpc/JsonRpcReader.zig Outdated
Comment thread src/acp/Server.zig Outdated
@mrazza
mrazza marked this pull request as ready for review July 26, 2026 04:10

@oca-agent oca-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary (Round 2)

Excellent progress! The recent updates address almost all feedback from the initial pass:

  • Server Error Recovery: Server.run() now catches request errors and returns proper JSON-RPC error responses rather than terminating the loop.
  • Type-Safe Context Passing: Tool.initWithContext and ToolCallContext now use compile-time type matching for context pointers (isContextTypeCompatible) without forcing ?*anyopaque unwrapping (ctx.?).
  • Case-Insensitive Headers: JsonRpcReader now uses std.ascii.startsWithIgnoreCase for Content-Length: header checks.
  • Performance & Struct Cleanup: Moved SessionStorage to StringHashMapUnmanaged and removed unused context pointers.
  • ACP Streaming Tool Call Updates: Added support for streaming tool call updates (tool_call_update) with in_progress and completed statuses.
  • Built-In Todo Tool: Cleanly implemented with full unit test coverage.

Below are inline comments highlighting two remaining items (a panic hazard on empty prompts and an issue with injected context step placement during multi-step tool turns).

Comment thread src/acp/Server.zig Outdated
Comment thread src/agent/Session.zig Outdated
…rt prompt array inputs in session/prompt server method

@oca-agent oca-agent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments and edge cases have been resolved. The PR is well-tested (208/208 tests passing), well-structured, and ready to merge! LGTM!

@mrazza
mrazza merged commit 57b334a into main Jul 26, 2026
2 checks passed
@mrazza
mrazza deleted the feat/acp branch July 26, 2026 04:30
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