Skip to content

fix(acp): seed provider handoff history - #8941

Merged
baxen merged 3 commits into
mainfrom
losing-acp-history
May 1, 2026
Merged

fix(acp): seed provider handoff history#8941
baxen merged 3 commits into
mainfrom
losing-acp-history

Conversation

@matt2e

@matt2e matt2e commented May 1, 2026

Copy link
Copy Markdown
Collaborator

There were two situations where the agent would not see the conversation history:

  • Continuing a thread with an ACP provider after relaunching the app (we configure ACP providers to not store session history)
  • Switching a thread over to an ACP provider

Signed-off-by: Matt Toohey <contact@matttoohey.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b8066f0c7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread crates/goose/src/acp/provider.rs Outdated
}

fn should_send_handoff_context(&self, messages: &[Message]) -> bool {
!self.handoff_context_sent.swap(true, Ordering::AcqRel) && has_handoff_context(messages)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Set handoff-sent flag only after prompt send succeeds

should_send_handoff_context flips handoff_context_sent before stream() enqueues the ACP prompt, so if prompt() fails (for example when the ACP client channel is temporarily unavailable), the retry path will never include the handoff memo even though the provider never actually received it. This can drop the intended prior-session context on the first successful request after a transient failure. Move the state transition to after a successful prompt() send (or roll it back on error).

Useful? React with 👍 / 👎.

matt2e added 2 commits May 1, 2026 16:35
Signed-off-by: Matt Toohey <contact@matttoohey.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cd2dfc3e0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

return None;
}

let handoff_context = formatted_messages.join("\n");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bound handoff memo size before building first ACP prompt

The new handoff path includes all prior agent-visible messages in a single memo, but there is no character/token cap before join("\n"). On long sessions (especially with large tool responses), the first ACP prompt can become too large and fail immediately with context/request-size errors, which blocks provider handoff for exactly the conversations this feature targets. Please cap or truncate the serialized history (e.g., by token/char budget and recency) before constructing the memo.

Useful? React with 👍 / 👎.

@matt2e
matt2e marked this pull request as draft May 1, 2026 07:02
@matt2e
matt2e marked this pull request as ready for review May 1, 2026 07:03

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4cd2dfc3e0

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +432 to +434
if claim.first_prompt {
self.handoff_context_sent.store(false, Ordering::Release);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reset handoff claim when first prompt fails asynchronously

Roll back handoff_context_sent not only when prompt() enqueueing fails, but also when the first prompt later fails via AcpUpdate::Error. Right now the flag is set in claim_handoff_context, and only the immediate send error path resets it; if ACP accepts the request locally but returns an error (e.g., transport hiccup or prompt rejection) before producing a response, retries will skip the handoff memo even though no successful first prompt completed, dropping prior conversation context on the next attempt.

Useful? React with 👍 / 👎.

@baxen baxen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a super clean approach, and i tested it out it works nicely

@baxen
baxen added this pull request to the merge queue May 1, 2026
Merged via the queue into main with commit c365e7b May 1, 2026
23 checks passed
@baxen
baxen deleted the losing-acp-history branch May 1, 2026 22:23
shafqatevo pushed a commit to shafqatevo/goose that referenced this pull request Aug 7, 2026
Signed-off-by: Matt Toohey <contact@matttoohey.com>
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