Skip to content

bug(agy-acp): multi-turn responses repeat entire conversation history #905

@chaodu-agent

Description

@chaodu-agent

Summary

agy-acp sends back the entire conversation history on every turn instead of only the new assistant response. Users see all previous responses repeated with each follow-up message.

Root Cause

agy --continue -p "prompt" dumps the full conversation output to stdout (all turns), not just the latest assistant reply. The adapter captures stdout verbatim and sends it as agent_message_chunk without filtering:

// agy-acp/src/main.rs
let text = String::from_utf8_lossy(&output.stdout).to_string();
// entire history sent back as agent_message_chunk

On turn 1: user sees response A.
On turn 2: user sees response A + response B.
On turn 3: user sees response A + response B + response C.

Expected Behavior

Each turn should only return the new assistant response for that turn:

  • Turn 1: user sees response A only
  • Turn 2: user sees response B only
  • Turn 3: user sees response C only

Affected Code

Reproduction

  1. Deploy openab with agy-acp adapter
  2. Send first message → get response A (correct)
  3. Send second message → get response A + response B (bug: A is repeated)
  4. Send third message → get A + B + C (grows every turn)

Options Considered

Option 1: Remove --continue entirely

  • Each agy -p call is stateless — no multi-turn context
  • Clean output, no history duplication
  • ❌ Loses all conversation context between turns

Option 2: Track byte offset of previous output

  • Store last_output_len per session, emit text[last_output_len..]
  • Simple implementation
  • ❌ Fragile — breaks if agy reformats previous turns or adds metadata between runs
  • --continue resumes the most recent conversation globally, unsafe for concurrent sessions

Option 3: Use --conversation <ID> + delta extraction ✅

  • On first prompt: run agy -p "prompt", capture full stdout, store per session
  • On subsequent prompts: run agy --conversation <ID> -p "prompt", capture full stdout, emit only the delta (new bytes beyond previous stored output)
  • Track the agy conversation ID per session
  • ✅ Append-only safe — --conversation output grows monotonically, previous turns don't change
  • ✅ Concurrent-session safe — each session targets a specific conversation ID, not "most recent"
  • ✅ Preserves multi-turn context

Option 4: Pipe full context in prompt text

  • Don't use --continue or --conversation, prepend previous turns in the prompt itself
  • openab already sends thread context, so agy gets it as one big prompt
  • ❌ Loses agy's native tool-use continuity and internal state
  • ❌ Token usage grows quadratically

Decision

Going with Option 3 — it preserves multi-turn context, is safe for concurrent sessions, and the delta extraction is reliable since --conversation output is append-only.

Environment

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions