Skip to content

Feature: Connect ACP and Ollama agents with shared skills, snapshots, and conversation handoffs - #151

Merged
DevMando merged 10 commits into
mainfrom
feature/acp-mcp-bridge
Dec 3, 2026
Merged

DevMando merged 10 commits into
mainfrom
feature/acp-mcp-bridge

Conversation

@DevMando

@DevMando DevMando commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Summary

This PR lets ACP agents, such as Codex, participate in the same MandoCode workflow as native Ollama agents. Users can exchange work between agents, reuse skills and snapshots, and carry conversation context when switching. Each agent keeps its own project, conversation, model, and permissions.

What users can do

  • Collaborate across agent types: mention open agents, check their status or recent messages, ask questions, delegate background tasks, send updates, and track or cancel assigned work.
  • Continue work when switching agents: choose whether to carry a recap generated by the agent being left. The recap accompanies the next request to the destination. Cancelling or failing to generate a recap leaves the source agent active.
  • Use the same snapshot controls: open Alt+C or /context-snapshot in ACP and native panes. ACP snapshot creation uses the connected ACP agent and its current model, without requiring Ollama. Imports survive failed or cancelled requests and are consumed once after success.
  • Reuse MandoCode skills: ACP agents can discover enabled skills, load their instructions, and read referenced text files. Project skills override matching user skills; disabled skills stay hidden.
  • Follow clearer conversations: each expandable exchange has one participant heading, Request/Reply sections, status updates in place, and a stable completion duration.
  • Use the preferred command spelling: /acp-agent codex and /acp-agent-mode work alongside the existing /agent-acp commands.

The PR also fixes a startup race that could hide agent-advertised commands, updates the Unreleased changelog, and moves the README support badge alongside the project badges.

Scope and boundaries

  • Context handoffs and snapshots transfer a text recap, not full provider memory, files, attachments, or tool state. Handoffs are optional; an explicit --resume continues the destination session without the handoff question.
  • Skill access is read-only. Referenced text reads stay inside the selected skill folder and do not execute scripts.
  • The built-in MCP bridge belongs to one pane and is revoked on stop, restart, or folder change. It can be disabled per ACP agent with mandoCodeMcp: false.
  • Native history, integration-management screens, and third-party MCP settings remain separate. Read-only review requests use native agents because MandoCode cannot enforce an external agent's editing permissions.

Validation

  • Full .NET 10 Release suite: 1,990 passed, one existing skip.
  • Real stdio MCP tests cover identity, lifecycle, cancellation, collaboration, snapshots, skill precedence, disabled skills, and resource boundaries.
  • Component and protocol tests cover snapshot creation without Ollama, import retries with images, handoff choices and failure handling, command aliases, compact exchange rendering, and command announcements arriving before session registration.
  • Final focused checks passed after the last wording change. The Windows workflow was also tested and confirmed working by the user.

Related epic: #144.

Make the project's support link easier to find in the README header and
remove the old Made with <3 by Mando badge, as requested.

- Place Buy Me a Coffee alongside the existing project and platform badges.
- Keep the footer support section as a short linked sentence instead of
  repeating the same badge at the bottom of the page.
- Keep the RazorConsole version badge unchanged for the next release.

Validation:
- Reviewed the header and footer Markdown/HTML and their link destinations.
- Confirmed the ACP feature documentation is excluded from this commit.
- git diff --cached --check passed.
Allow ACP clients to supply MCP servers when opening or continuing a
session. Previously these requests always sent an empty server list, so
an external agent could not receive MandoCode's host tools through ACP.

- Accept an optional MCP server collection for session/new, session/resume,
  and session/load without changing existing callers' empty-list behavior.
- Forward stdio commands, arguments, and environment entries through the
  existing ACP protocol types and JSON serialization.
- Add wire-level regression coverage for all three lifecycle requests,
  including the command, arguments, and environment payload.

Validation:
- The three new session-lifecycle cases passed in the focused client run.
- The combined branch passed 1,976 tests with one existing skip after the
  bridge and UI integration; this commit is its protocol foundation.
- git diff --cached --check passed.
Give external ACP agents access to MandoCode's open agents and saved
conversation recaps through a built-in mandocode MCP server. ACP and
native Ollama agents can exchange questions and tasks while retaining
their own folders, conversations, models, and approval settings.

Bridge and lifecycle:
- Host a private named-pipe MCP endpoint per ACP runtime and expose it to
  adapters through an internal, protocol-only stdio helper.
- Require a random credential and current-user pipe access; reject stale
  credentials and revoke the endpoint on stop, restart, or folder change.
- Pass the bridge definition when creating, resuming, loading, or clearing
  ACP conversations. Allow per-agent opt-out with mandoCodeMcp: false.

Collaboration and context:
- Reuse native directory, messaging, question, delegation, handoff, job
  update, cancellation, and progress tools rather than duplicating them.
- Derive tool identity and call ancestry from the owning pane, preserving
  job ownership, call-loop protection, and request cancellation.
- Accept tool calls only during an active ACP request and cancel pending
  peer questions when that request ends.
- Enable the Agents group in ACP mention pickers when the bridge exists.
  Resolve agent mentions ahead of same-named files; explicit file paths
  still attach files normally.
- Route incoming peer questions/tasks through the ACP runtime and consume
  inbox reports on the next request without duplicating visible prompts.
- Expose list_snapshots, read_snapshot, and bounded create_snapshot tools
  with source-project metadata and reference-material descriptions.

Boundaries:
- Decline incoming read-only reviews for ACP recipients because MandoCode
  cannot enforce an external agent's editing permissions.
- Keep native history, skills, and third-party MCP configuration separate.
- Document behavior, opt-out, and limitations in the README and changelog.

Validation:
- Real MCP stdio subprocess tests cover discovery, active-turn gating,
  identity, call ancestry, loop rejection, snapshot save/read/validation,
  cancellation, credential rejection, and connection revocation.
- Component tests cover agent/file name collisions, inbox consumption,
  clipboard images, and project-change prompt sequencing.
- Manual testing confirmed the ACP mention picker and a peer exchange.
- Combined branch: 1,976 passed, one existing skip; staged diff check clean.
Make agent exchanges easier to scan by showing the participants once and
keeping the request and reply in one expandable section. Previously the
sender repeated in the section title, nested request panel, and direction
line, followed by a redundant delivery confirmation.

Conversation presentation:
- Use a single sender-to-recipient heading with Question, Task, Review,
  Handoff, or Message to identify the interaction.
- Render compact Request/Reply sections instead of nested bordered boxes.
- Use Reply for incoming peer responses instead of repeating the agent's
  name, while preserving normal headings for user-facing conversations.
- Mark successful incoming requests Completed without appending another
  Response delivered message.
- Update background acceptance in place instead of adding an accepted
  message and repeating the interaction ID and keep-chatting instructions.
- Apply the same presentation to native and ACP agent exchanges.

Status and timing:
- Preserve the existing exchange's waiting status when a nested inbox
  message is added; standalone messages say Queued rather than implying
  the recipient has read or acted on them.
- Keep failures, cancellations, and next-turn inbox notices visible.
- Show Started and completed duration instead of two competing timestamps.
  Keep background job/message references in expanded metadata.
- Freeze the completion time so later messages do not inflate duration,
  and retain that timestamp when an archived conversation is reopened.
- Preserve expansion state as status changes, so updates do not collapse
  details the user is reading.

Validation:
- Added layout coverage for one participant heading, unboxed request/reply
  content, status-only completion, stable duration, and job references.
- Updated the shared-question layout expectations for the compact renderer.
- Focused exchange, interaction, archive, and MCP checks passed, including
  nested inbox messages that must not reset a waiting question's status.
- Final full suite: 1,976 passed, one existing skip. An ACP command test
  failed in an earlier run, passed on its focused rerun, and passed in the
  final full run. No test failure remains.
- git diff --cached --check passed.
Prevent an intermittent startup race that could leave an external agent's
commands missing even though initialization and session creation succeeded.
The JSON-RPC response and notification queues dispatch independently, so
commands could arrive before the new session ID had been registered.

- Serialize session/new and session/resume registration with a shared gate.
- When an update targets an unregistered session, wait for any session open
  operation to finish, then look up the returned session again.
- Deliver the update after registration while retaining diagnostics for
  genuinely unknown sessions. Existing registered sessions keep their
  normal update path.
- Release the registration gate on failure and cancellation as well as
  successful startup; avoid replacing the race with a longer timeout.

Validation:
- Added a regression that deliberately announces compact before returning
  the session/new response and checks that the command is retained.
- ACP client and process tests passed in the focused and full-suite runs.
- The previously intermittent announced-commands test passed in the final
  full run: 1,990 passed, one existing skip across the combined branch.
- Staged diff whitespace check passed.
Give ACP users the same snapshot picker, capture, and import flow as native
agents. Creating a snapshot now uses the connected ACP agent and its
current model instead of requiring an Ollama summarizer.

Snapshot controls and generation:
- Enable Alt+C, /context-snap-import, and /context-snap-create in ACP panes.
  Add /context-snapshot as a convenient entry point to the shared picker.
- Capture the visible ACP conversation with source-agent/project metadata,
  keeping native conversation history and native memory payloads separate.
- Add a provider callback to the shared panel so ACP recaps use the active
  runtime, while native snapshots retain their existing Ollama flow.
- Hide the Ollama model selector and avoid Ollama model-list/title requests
  when an ACP summarizer is supplied. A blank name gets a conversation title.
- Ask for a concise recap without tools or edits, using current ACP context
  plus a bounded visible transcript. Suppress recap output in the chat while
  retaining errors and actual tool activity through the normal ACP driver.

Import behavior:
- Attach queued recaps as reference text to the next actual ACP request.
  Mentions inside a recap do not expand into file attachments.
- Preserve real user attachments, including clipboard images, and keep
  imported recap text out of the visible user-message history.
- Consume imports once after a successful request; retain them after
  cancellation, provider failure, or a failed project-context update.
- Clear pending captures and queued imports on an explicit /clear.

Validation:
- Added ACP capture isolation, import/retry, clipboard-image preservation,
  project-update failure, queued-context clearing, and recap-output checks.
- Added shared-panel coverage proving an ACP callback saves a snapshot
  without Ollama and exposes Create/Back rather than a model picker.
- Existing native snapshot and keyboard-layout checks remain covered.
- Combined branch: 1,990 passed, one existing skip; manual testing confirmed
  the new flow. Final focused checks and staged whitespace checks passed.
Let users type /acp-agent codex and /acp-agent-mode while keeping all
existing /agent-acp commands compatible. Avoid requiring a configuration
migration or changing ACP agent registration names.

- Normalize the new spellings to the existing internal command routes.
- Preserve the original argument casing for agent names and command flags;
  retain case-insensitive command matching and dispatch behavior.
- Advertise both new spellings in the command catalog. Catalog reservation
  also prevents agent-advertised commands from taking over these controls.
- Document the compatible spellings in the ACP setup section and changelog.

Validation:
- Added a component-level list-command dispatch check for /acp-agent.
- Verify mixed-case command input retains verbatim arguments and the
  /acp-agent-mode spelling resolves to the existing mode command.
- Focused ACP command/catalog checks and the combined full suite passed:
  1,990 passed, one existing skip. Manual testing confirmed the new flow.
- Staged diff whitespace check passed.
Offer an explicit context handoff when switching a pane between native
Ollama and ACP agents, or between configured ACP agents. Users can carry a
recap without manually creating and importing a saved snapshot first.

- Offer Continue with a recap, Switch without a recap, and Cancel when the
  source agent has conversation text. Empty sources switch directly.
- Generate the recap with the agent being left: the current native model
  uses the existing isolated summarizer, while ACP uses its connected
  runtime and current model through the new snapshot callback.
- Finish recap generation before disposing the source runtime. Cancellation,
  provider failure, or an empty recap leaves the source agent active.
- Queue an in-memory context snapshot for the destination's next actual
  user request rather than immediately continuing earlier work or creating
  a durable saved snapshot the user did not request.
- Preserve the underlying native conversation. Carry text context rather
  than claiming to restore another provider's session, tools, or attachments.
- Respect an explicit --resume request by continuing the destination
  session without asking the handoff question.
- Update the switch wording and README to explain the opt-in behavior.

Validation:
- Cover all three choices plus dismissal, with source-generated recap and
  project/agent provenance checks.
- Cover recap-provider failure retaining the source agent and conversation.
- Assert neither visible source nor native history is replaced while the
  handoff choice is prepared.
- Focused handoff/snapshot tests and final wording checks passed; combined
  full suite: 1,990 passed, one existing skip. User confirmed manual testing.
- Staged diff whitespace check passed.
Let external ACP agents discover and read the same enabled user/project
skills available to native agents. Expose read-only skill tools through
the existing per-pane MCP bridge so users do not have to duplicate skill
instructions in each adapter's separate configuration.

Skill discovery and loading:
- Add list_skills with names, descriptions, source type, and source paths.
- Add load_skill with workflow instructions and the skill's base directory.
- Reuse SkillLoader for case-insensitive lookup, project-over-user
  precedence, and the SKILL.md/SKILL.md.disabled enable convention.
- Reload on each lookup so edits, enable changes, and current-project
  changes are reflected rather than exposing a stale copy.
- Bound long instruction output and point callers to the resource reader
  when they need the complete SKILL.md text.

Referenced resources and boundaries:
- Add read_skill_resource for text files relative to the selected skill's
  folder; reuse the filesystem guard to reject traversal and links that
  escape that folder, and reject absolute paths.
- Limit text files to 1 MiB, reads to 64,000 characters, and provide
  offset-based continuation. Reject binary content and do not execute
  scripts or expose skill editing through these tools.
- Inherit the bridge's owning-pane identity, active-request gating,
  credential checks, cancellation, and runtime revocation behavior.
- Explain that skill loading stays within the user's request and existing
  permissions; it does not authorize unrelated work or bypass approvals.
- Update skills documentation and command explanations. Native skill
  management and third-party MCP settings remain separate.

Validation:
- Real stdio MCP coverage checks discovery, project overrides, disabled
  file exclusion, instruction loading, text-resource reads, traversal
  rejection, and immediate fallback when a project override is disabled.
- Final focused skills/handoff checks passed; the combined full suite
  passed 1,990 tests with one existing skip. User confirmed manual testing.
- The README patch contains only the reviewed skill-access documentation;
  the badge cleanup was already committed separately in 0f67062.
- Staged scope and whitespace checks passed.
Lead the Unreleased section with the user-facing collaboration, shared
skills, snapshot, and context-handoff capabilities delivered by this branch.

- Add concise highlights for ACP/native collaboration, skill access,
  snapshots, handoffs, and compact agent exchanges.
- Correct earlier restriction notes that still described snapshots, image
  paste, and the agent mention picker as unavailable to ACP panes.
- Clarify that native skill management, native history, and third-party
  MCP settings remain separate from read-only shared skill access.
- Record the startup notification race fix and the README support badge
  change alongside their relevant release-note categories.
- Record the final 1,990 passing tests, one existing skip, targeted checks,
  real stdio MCP coverage, and user-confirmed manual validation.

Validation: reviewed against the implemented command restrictions and
committed changes; git diff --check passed. Documentation-only update.
@DevMando
DevMando merged commit 53ddc9f into main Dec 3, 2026
2 checks 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.

1 participant