feat(acp): integrate ACP harness for agent communication - #4072
Conversation
- 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.
Soffi AI SummaryThis 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:
Updated: 2026-09-07 14:34 UTC |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
plural deploy to dev |
Greptile SummaryThe PR adds a provider-neutral ACP harness and migrates the Codex and OpenCode integrations onto its session, transport, update, and tool-call abstractions.
Confidence Score: 5/5The 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.
|
| 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
- Add context cancellation checks in `ReadTextFile` for robustness. - Introduce a limit on text file read size with `maxTextFileBytes`. - Implement `contextReader
- 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.
|
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
…-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.
- 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.
- 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.
acppackage for handling ACP session lifecycle.acp.go,acp_session.go,acp_turn.go, andacp_client.gofor structuring ACP tool logic and session management.ExportSessionmethod for reusability.artifacts.go.go.sumwith new dependencies for ACP SDK integration.Test Plan
Test environment: https://console.plrl-dev-aws.onplural.sh/
Checklist
Plural Flow: console