Skip to content

[DRAFT] fix(agent): preserve copilot-acp session context across requests - #5335

Closed
MestreY0d4-Uninter wants to merge 2 commits into
NousResearch:mainfrom
MestreY0d4-Uninter:fix/acp-session-context
Closed

[DRAFT] fix(agent): preserve copilot-acp session context across requests#5335
MestreY0d4-Uninter wants to merge 2 commits into
NousResearch:mainfrom
MestreY0d4-Uninter:fix/acp-session-context

Conversation

@MestreY0d4-Uninter

@MestreY0d4-Uninter MestreY0d4-Uninter commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Depends on #4536.
Please review/merge this after the ACP tool-call bridge lands, since this follow-up assumes that base.

I’m opening it early to reduce the risk of upstream drift while #4536 is still pending.

Summary

This PR improves the copilot-acp integration by making session behavior much closer to a native conversational backend.

Instead of rebuilding ACP state in a brittle way on every request, this change keeps the session/process alive across turns and replays only the incremental delta when the message history is an exact prefix extension.

What changed

  • preserve ACP process/session across requests
  • replay only new messages when the conversation history is a strict extension
  • reset the ACP session when history/model changes incompatibly
  • improve message serialization so assistant tool_calls, tool results, and richer message content survive the ACP bridge
  • gracefully fall back when session.model.switchTo is unavailable in the current ACP runtime

Why

The tool-call bridge fixed the biggest behavioral bug, but ACP conversations still felt less native than other providers because context/session handling was weaker.

This PR improves continuity and makes ACP much more usable for multi-turn workflows.

Validation

Automated

  • python3 -m py_compile agent/copilot_acp_client.py tests/agent/test_copilot_acp_client.py
  • uv run --extra dev python -m pytest -o addopts='' tests/agent/test_copilot_acp_client.py -q
  • Result: 5 passed

Manual

Validated with a real ACP multi-turn flow on the rebased branch:

  1. first request returns OK
  2. second request reuses prior context and returns CONTEXTO_OK

Notes

This PR does not claim strong model enforcement in ACP. It improves session/context behavior on top of the current runtime.

Mateus Scheuer Macedo added 2 commits April 5, 2026 21:15
(cherry picked from commit 84ef973ff0f6cc13eb7a05ca479793fb8c21e8a6)
@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor Author

Stacked follow-up to #4536.

Opened as draft to avoid upstream drift while the base ACP tool-call bridge is still pending.
Please review/merge this after #4536.

Related follow-ups in the same stack:

@MestreY0d4-Uninter

Copy link
Copy Markdown
Contributor Author

Closing as stale/superseded by later ACP integration changes. I re-audited this against a clean origin/main worktree: parts of the ACP/session behavior were covered by later ACP follow-ups, but this stacked draft no longer represents a clean, mergeable delta on top of current main. If any residual gap still matters, I'll re-extract it as a small focused PR against current main.

@MestreY0d4-Uninter
MestreY0d4-Uninter deleted the fix/acp-session-context branch April 27, 2026 01:42
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