Skip to content

feat(acp): integrate ACP harness for agent communication - #4072

Open
floreks wants to merge 21 commits into
masterfrom
sebastian/prod-5162-consider-moving-agent-harness-to-use-agent-client-protocol
Open

feat(acp): integrate ACP harness for agent communication#4072
floreks wants to merge 21 commits into
masterfrom
sebastian/prod-5162-consider-moving-agent-harness-to-use-agent-client-protocol

Conversation

@floreks

@floreks floreks commented Aug 28, 2026

Copy link
Copy Markdown
Member
  • Added new acp package for handling ACP session lifecycle.
  • Implemented provider-neutral Agent Client Protocol (ACP) harness.
  • Created acp.go, acp_session.go, acp_turn.go, and acp_client.go for structuring ACP tool logic and session management.
  • Extracted opencode session export functionality into ExportSession method for reusability.
  • Updated imports to add support for ACP logic and made necessary code refactoring for cleaner management.
  • Removed redundant session export logic from artifacts.go.
  • Updated go.sum with new dependencies for ACP SDK integration.

Test Plan

Test environment: https://console.plrl-dev-aws.onplural.sh/

Checklist

  • I have added a meaningful title and summary to convey the impact of this PR to a user.
  • If required, I have updated the Plural documentation accordingly.
  • I have added tests to cover my changes.
  • I have deployed the agent to a test environment and verified that it works as expected (required only when changing agent code).

Plural Flow: console

- Added new `acp` package for handling ACP session lifecycle.
- Implemented provider-neutral Agent Client Protocol (ACP) harness.
- Created `acp.go`, `acp_session.go`, `acp_turn.go`, and `acp_client.go` for structuring ACP tool logic and session management.
- Extracted opencode session export functionality into `ExportSession` method for reusability.
- Updated imports to add support for ACP logic and made necessary code refactoring for cleaner management.
- Removed redundant session export logic from `artifacts.go`.
- Updated `go.sum` with new dependencies for ACP SDK integration.
@floreks floreks self-assigned this Aug 28, 2026
@floreks floreks added the enhancement New feature or request label Aug 28, 2026
@linear

linear Bot commented Aug 28, 2026

Copy link
Copy Markdown

PROD-5162

@soffi-ai

soffi-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Soffi AI Summary

This PR migrates the agent harness in the deployment operator from a bespoke per-tool communication protocol to the Agent Client Protocol (ACP) — a provider-neutral, SDK-backed session lifecycle standard. The motivation is to unify how agent harnesses (Opencode, Codex, and future tools) communicate with the console, replacing fragile, tool-specific streaming/FIFO implementations with a single, well-tested ACP session abstraction.

Key changes:

  • Introduces a new acp package (engine.go, session.go, client.go, tool_call.go, updates.go, types.go) that implements the full ACP session lifecycle: initialization, session creation/resumption, prompt turns, tool-call output handling, usage tracking, and timeout/cancellation semantics.
  • Removes the Codex-specific streaming protocol (codex_stream.go, codex_types.go, codex_templates.go) and replaces it with a thin ACP environment adapter (acp_environment.go) so Codex now communicates over ACP instead of a custom FIFO-based stream.
  • Retains the Codex agent wrapper (codex/agent.go, agent_config.go) for process lifecycle management and model/settings configuration, now decoupled from transport details.
  • Adds comprehensive test coverage for the new ACP layer: engine_test.go (535 lines), client_test.go, session_test.go, tool_call_test.go, and supporting Codex adapter tests.
  • Updates CI/CD workflows to track the new OPENCODE_VERSION and bumps go.mod/go.sum for the ACP Go SDK dependency.

Updated: 2026-09-07 14:34 UTC

Deploy in Soffi

@socket-security

socket-security Bot commented Aug 28, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgolang/​github.com/​coder/​acp-go-sdk@​v0.13.599100100100100

View full report

@floreks

floreks commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

plural deploy to dev

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds a provider-neutral ACP harness and migrates the Codex and OpenCode integrations onto its session, transport, update, and tool-call abstractions.

  • Adds bounded ACP filesystem callbacks, session lifecycle management, and protocol update handling.
  • Refactors Codex and OpenCode runtime configuration, transport, session export, and container packaging.
  • Extends execution/runtime primitives and Nexus response handling to support the ACP-based integrations.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains from the previously reported ACP file-read issues.

The ACP client now caps file reads and opens peer-selected paths nonblockingly before rejecting non-regular files, resolving both previously reported failure paths.

Important Files Changed

Filename Overview
go/deployment-operator/pkg/agentrun-harness/tool/acp/client.go Implements ACP client callbacks with session validation, bounded regular-file reads, nonblocking file opens, and unattended-run behavior.
go/deployment-operator/pkg/agentrun-harness/tool/acp/engine.go Coordinates the provider-neutral ACP engine and session lifecycle.
go/deployment-operator/pkg/agentrun-harness/tool/acp/session.go Implements ACP connection and session state management shared by agent providers.
go/deployment-operator/pkg/agentrun-harness/tool/codex/agent.go Migrates Codex agent execution and artifact export onto the ACP harness.
go/deployment-operator/pkg/agentrun-harness/tool/opencode/agent.go Migrates OpenCode agent execution onto the shared ACP harness.
go/deployment-operator/pkg/harness/exec/exec_stdio.go Adds standard-I/O process handling required by ACP transports.
go/nexus/internal/router/openai_responses.go Updates OpenAI response routing behavior and its associated tests for the new integration requirements.
go/deployment-operator/dockerfiles/agent-harness/codex.Dockerfile Packages the Codex ACP adapter and pinned native Codex CLI into the harness image.

Reviews (6): Last reviewed commit: "feat(acp): handle non-blocking FIFO read..." | Re-trigger Greptile

Comment thread go/deployment-operator/pkg/agentrun-harness/tool/acp/acp_client.go Outdated
- Add context cancellation checks in `ReadTextFile` for robustness.
- Introduce a limit on text file read size with `maxTextFileBytes`.
- Implement `contextReader
@floreks

floreks commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

@greptileai

- Bump OPENCODE_VERSION from 1.17.3 to 1.18.23 for deployment compatibility.
- Add `TestNewOpenCodeSelectsConfiguredAgentForRunMode` to verify agent selection based on run mode.
- Update `opencode_args_test.go` to use `Default*Agent` constants.
- Change `opencode_types.go` to export `Default*Agent` constants.
- Modify `opencode.go` files to utilize exported `Default*Agent` constants.
@floreks

floreks commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

plural deploy to dev

- Introduce `sessionAttempt` and `sessionDetails` structs for clearer separation of attempts and session configurations
- Implement session attempt lifecycle methods: `startAttempt`, `run`, `stop`, `initialize`, `openSession`, `createSession`, `resumeSession`
- Add error handling improvements: `fail`, `promptFailure`
- Consolidate process rejection logic into `rejectProcess`
- Refine session configuration with `setModelConfig` and `setModeConfig` functions for cleaner configuration flow
- Bump `opencode` version from 1.17.3 to 1.18.23 in deployment workflow file for compatibility.
- Add test `TestToolOutputPrefersContentOverRawOutput` to prioritize content over raw output in tool messages.
- Add test `TestToolOutputFallsBackToRawOutputWithoutContent` to ensure raw output is used when content is unavailable.
- Simplify `normalizeUsage` function logic to use `max` for total token calculation.
- Refactor `acp_turn.go` to improve tool output handling by checking and formatting content and raw output effectively.
…-consider-moving-agent-harness-to-use-agent-client-protocol
- Update `ConfigureSystemPrompt` and `systemPromptInput` methods to use pointer receivers in `tool/v1/tool.go`
- Modify `ConfigureSkills` and related methods to use pointer receivers in `v1/skills.go`
- Change test functions in `acp_test.go` to test new tool behaviors
- Simplify tool management logic by removing redundant flusher handlers in `acp.go` and `acp_turn.go`
- Enhance cumulative cost tracking by introducing a new `RecordCumulativeCost` method
- Introduced `newSessionUpdates` to handle pre-response session updates
- Enhanced `NewSession` to process updates using `SessionUpdate`
- Added test `TestRunPromptHandlesUpdatesSentBeforeNewSessionResponse` to verify update handling order
- Added test `TestRunPromptRejectsMismatchedInitialSessionUpdate` to ensure proper session update matching
- Added test `TestSessionUpdateRejectsEmptySessionIDBeforeBinding` to enforce session ID validation
- Refactored session config functions into methods: `setSessionConfig`, `setModelConfig`, `setModeConfig`
- Introduced `startAttempt` for clearer session initiation logic
- Created `validate` method for comprehensive tool configuration checks
- Updated error messages for consistency with lowecase conventions
- Reorganized `toolCall` and `toolUpdateEvents` to streamline tool communication logic
@floreks

floreks commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

@greptileai

…-consider-moving-agent-harness-to-use-agent-client-protocol
- Adjust `opencode.go` to use `DefaultReviewAgent` consistently across logic.
- Resolve potential errors due to incorrect agent name casing.
- Change object creation in `templates_test.go` to use pointer receiver syntax
- Correct casing of `DefaultReviewAgent` in `opencode_args_test.go`
…-consider-moving-agent-harness-to-use-agent-client-protocol
…-consider-moving-agent-harness-to-use-agent-client-protocol

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
…verage

- Introduced ACP transport for Opencode with provider-specific session handling in `transport.go`.
- Refactored tool runtime API to abstract provider-neutral operations in `runtime_types.go`.
- Added comprehensive tests for ACP transport in `transport_test.go` and Agent lifecycle in `runtime_test.go`.
- Enhanced tool configuration logic, consolidating system prompt methods with `configureSystemPrompt`.
- Improved model selection and OpenCode provider prefix handling in `opencode_templates_test.go` and `settings_test.go`.
- Simplified file-system handling and lifecycle hooks for agents.
@floreks
floreks requested a review from a team as a code owner September 4, 2026 09:15
- Deleted `codex` package and its implementation files (`artifacts.go`, `codex.go`, `codex_stream.go`) to streamline codebase.
- Removed Codex-specific tests from `codex_stream_test.go`.
…ion and tests

- Updated Codex configuration to use `Settings` instead of `Profile` for better semantic alignment.
- Replaced `Profile`-based logic with `Settings` in tests and runtime handling (`agent_config_test.go`, `templates_test.go`, and others).
- Removed outdated profiles: `analysisProfile`, `autonomousProfile`, and `reviewProfile` in favor of streamlined ACP settings.
- Enhanced diagnostic handling with detailed process STDERR tailing in `exec_stdio` package.
- Deprecated `chat` wire API, enforced `responses` wire API throughout Codex logic (`agent_config.go`, `runtime_config.go`, etc.).
- Improved runtime failure handling by introducing structured error propagation in `session.go`.
- Adjusted template rendering to align with the updated Codex `settings` structure (`config.toml.gotmpl`).
…ession workflow, and CI dependencies

- **Router Enhancements**:
  - Added support for streaming error handling in OpenAI Responses.
  - Preserved raw OpenAI payloads upstream for better compatibility and future extensibility.
  - Introduced new request parsing and error conversion mechanisms in `openai_responses.go`.
  - Improved session and response failure diagnostics.
  - Added unit tests to enforce proper handling of raw OpenAI requests, streaming errors, and failure conditions.

- **Session Workflow Updates**:
  - Replaced `killAndWait` with `stopAndWait` for improved process termination semantics.
  - Updated `engine_test.go` and `session.go` to distinguish between killed and stopped states.
  - Preserved stop reason during cleanup and spontaneous exit scenarios.
  - Ensured session updates are handled consistently.

- **Codex Dependency Updates**:
  - Bumped Codex version to `1.10.0` in both `codex.Dockerfile` and CI workflows.
  - Introduced native Codex binaries integration for streamlined builds and runtime.
  - Adjusted npm symlink setup to include new binary installation.

- **Test Coverage**:
  - Added comprehensive tests for session handling, streaming errors, and OpenAI response workflows.
  - Verified compatibility with updated Codex and session lifecycle across multiple test scenarios.
- Increased default stop timeout to 15 seconds in `engine.go`.
- Updated error assignment syntax in `session.go` for consistency.
- Improved session cleanup to distinguish between stop and kill processes.
- Enhanced error handling during session finalization and cleanup.
- Updated `testProcess` in `engine_test.go` to support `stopReportsKill` for more accurate test scenarios.
@floreks

floreks commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

@greptileai

Comment thread go/deployment-operator/pkg/agentrun-harness/tool/acp/client.go Outdated
- Updated `client.go` to open files with `O_NONBLOCK` for improved non-blocking behavior.
- Added `TestClientRejectsFIFOWithoutBlocking` to validate FIFO handling without blocking.
- Included `syscall` and `time` imports for enhanced test and runtime functionality.
@floreks

floreks commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant