Skip to content

fix(acp): tolerate CodeBuddy dialect and stop misreporting empty turns as needs-auth - #692

Merged
piorpua merged 1 commit into
mainfrom
aionissue/fix-2.1.41-136586749-001
Jul 27, 2026
Merged

fix(acp): tolerate CodeBuddy dialect and stop misreporting empty turns as needs-auth#692
piorpua merged 1 commit into
mainfrom
aionissue/fix-2.1.41-136586749-001

Conversation

@piorpua

@piorpua piorpua commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Description

Fix for Sentry 136586749 / ELECTRON-3R1.

Empty team-collaboration turns from the CodeBuddy ACP backend were surfaced as "the agent may need you to sign in (Login with iOA)" even when the channel was online and authenticated. CodeBuddy unconditionally advertises authMethods, so every empty end_turn fell through to the auth-hint fallback regardless of the real cause. Separately, CodeBuddy's non-standard session_end / compact-maxtoken notifications were hard-rejected as -32602 and silently dropped, discarding a signal that could have attributed the empty turn correctly.

Changes

  • Local tolerant pre-parse layer (protocol/acp_dialect.rs, pure function): classifies each raw incoming JSON-RPC line and absorbs CodeBuddy's non-standard session_end and compact-maxtoken / emergency-auto notifications before the vendored agent-client-protocol schema hard-rejects them as -32602. Every other line — including genuinely malformed input and other unknown variants — is forwarded unchanged so the SDK still surfaces real errors. Wire criteria are grounded in this issue's captured logs.txt payloads. No vendored-crate edits.
  • Transport switch to first-party Lines interception: the SDK transport moves from ByteStreams to a first-party Lines interception point (equivalent newline framing) and raises an internal-only AcpDialectSignal when a dialect line is absorbed. The signal never counts as visible output and is never forwarded to the WebSocket; the relay and message_service discard it like SegmentBreak. Enables the tokio-util codec feature.
  • Empty-turn judgment convergence: a dialect signal observed within the turn / near-window now yields the new ACP_EMPTY_TURN_TOKEN_LIMIT tip (possibility wording) ahead of the auth hint, demoting authMethods-only empty turns to the last-resort ACP_EMPTY_TURN_NEEDS_AUTH fallback. The existing stderr terminal-error path is unchanged and the kilo-style authMethods fallback is kept (not deleted). The new tip does not set needs_auth, so it never reflects the agent as unavailable.

Tests

Adds unit / contract tests for line classification, the judgment priority (token signal beats auth hint; the reported clean empty turn still falls back to needs-auth), the turn-observation drain, and relay forwarding / needs_auth guardrails.

  • cargo fmt --all -- --check — exit 0
  • cargo clippy -p aionui-ai-agent -p aionui-conversation -- -D warnings — exit 0
  • cargo test -p aionui-ai-agent -p aionui-conversation — exit 0 (779 aionui-ai-agent lib tests + aionui-conversation relay guardrails, 0 failed)

Reviewer notes

  • Highest-attention point: the ByteStreams → Lines transport switch touches the incoming framing path shared by all ACP backends, not just CodeBuddy. Please confirm equivalent framing and no regression for other ACP CLIs (claude / codex / gemini).
  • Over-absorption guard: only exact-criteria session_end / compact-maxtoken lines are absorbed; everything else (including truly malformed messages) is forwarded and still surfaces -32602 as before.
  • Observability: absorbed dialect lines no longer produce the SDK's -32602 warn; a local info-level structured log records the absorption (kind / session_id / marker only, no sensitive payload).
  • CodeBuddy's internal reason for the empty end_turn is cross-boundary and intentionally not asserted.
  • No database / schema / migration changes.

Related

  • Sentry 136586749 / ELECTRON-3R1 (reported on AionUi 2.1.41, production, module agent-team)
  • Frontend counterpart PR in iOfficeAI/AionUi provides the localized copy for the softened ACP_EMPTY_TURN_NEEDS_AUTH and the new ACP_EMPTY_TURN_TOKEN_LIMIT tips.

Pending manual verification

  • Live end-to-end CodeBuddy reproduction: empty EndTurn no longer shows the hard "Login with iOA" assertion.
  • Dialect absorption in the running app (session_end / compact-maxtoken no longer -32602), and ACP_EMPTY_TURN_TOKEN_LIMIT produced when a real token-pressure signal is present.
  • kilo-style unauthenticated login-guidance non-regression.

…s as needs-auth

Empty team-collaboration turns from the CodeBuddy ACP backend were surfaced
as "the agent may need you to sign in (Login with iOA)" even when the channel
was online and authenticated. CodeBuddy unconditionally advertises authMethods,
so every empty end_turn fell through to the auth-hint fallback regardless of the
real cause (Sentry 136586749 / ELECTRON-3R1).

- Add a local tolerant pre-parse layer (protocol/acp_dialect.rs) that classifies
  each raw incoming JSON-RPC line and absorbs CodeBuddy's non-standard
  session_end and compact-maxtoken / emergency-auto notifications before the
  vendored agent-client-protocol schema hard-rejects them as -32602. Every other
  line, including genuinely malformed input and other unknown variants, is
  forwarded unchanged so the SDK still surfaces real errors. Wire criteria are
  grounded in this issue's captured logs.txt payloads.
- Switch the SDK transport from ByteStreams to the first-party Lines interception
  point (equivalent newline framing) and raise an internal-only AcpDialectSignal
  when a dialect line is absorbed. The signal never counts as visible output and
  is never forwarded to the WebSocket; the relay and message_service discard it
  like SegmentBreak. Enable the tokio-util "codec" feature for the line codec.
- Converge the empty-turn judgment: a dialect signal observed within the turn /
  near-window now yields the new ACP_EMPTY_TURN_TOKEN_LIMIT tip (possibility
  wording) ahead of the auth hint, demoting authMethods-only empty turns to the
  last-resort ACP_EMPTY_TURN_NEEDS_AUTH fallback. The existing stderr
  terminal-error path is unchanged, and the kilo-style authMethods fallback is
  kept (not deleted). The new tip does not set needs_auth, so it never reflects
  the agent as unavailable.

Adds unit tests for line classification, the judgment priority (token signal
beats auth hint; the reported clean empty turn still falls back to needs-auth),
the turn-observation drain, and relay forwarding / needs-auth guardrails.
@piorpua
piorpua merged commit 572f3c1 into main Jul 27, 2026
6 checks passed
@piorpua
piorpua deleted the aionissue/fix-2.1.41-136586749-001 branch July 27, 2026 10:22
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