Skip to content

fix(agent): notice a closed channel while an acknowledgement waits - #2209

Open
Benoît Cortier (CBenoit) wants to merge 1 commit into
masterfrom
cbenoit-pending-ack-backpressure
Open

Benoît Cortier (CBenoit) wants to merge 1 commit into
masterfrom
cbenoit-pending-ack-backpressure

Conversation

@CBenoit

Copy link
Copy Markdown
Member

An acknowledgement sent while the outbound buffer was full blocked the channel's stream loop, so it stopped reading the Authority's messages.
When the Authority ended its response but kept the request open, the Agent never saw the closure, never reconnected, and logged nothing.

The loop now keeps the acknowledgement until the stream has room, as it does for reports, and keeps reading meanwhile.
A closure drops it, as for any acknowledgement of a closed stream: the Authority repeats a renewal request and Hello reconciles the config.
Acknowledgements stay in order, and reports wait behind them; a dropped channel sends the pending one before those still queued.

Possible follow-up: the contract could also require the Authority to reset the request half when it ends a stream, as defence in depth for clients that stop reading.

An acknowledgement sent while the outbound buffer was full blocked the channel's stream loop, so it stopped reading the Authority's messages.
When the Authority ended its response but kept the request open, the Agent never saw the closure, never reconnected, and logged nothing.

The loop now keeps the acknowledgement until the stream has room, as it does for reports, and keeps reading meanwhile.
A closure drops it, as for any acknowledgement of a closed stream: the Authority repeats a renewal request and `Hello` reconciles the config.
Acknowledgements stay in order, and reports wait behind them; a dropped channel sends the pending one before those still queued.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 22:22
@CBenoit

Copy link
Copy Markdown
Member Author

Acceptance evidence for 7bdbfcf:

  • Red-green: a_full_outbound_buffer_with_a_pending_ack_does_not_block_reopening fails with master's stream.rs (no closure within the wait) and passes with the fix.
  • a_dropped_channel_sends_a_pending_ack_before_the_queued_ones passes on master too; it guards the caller-drop order of §Closing. A mutant that keeps reading the acknowledgement queue while one is pending fails it.
  • cargo test -p agent-channel-client: 145 passed. cargo clippy -p agent-channel-client --all-targets -- -D warnings: clean. rustfmt: clean.
  • Fresh-context review on the frozen commit: approve. Its one optional suggestion, inlining pending_ack.take() into the if let, is not applied: the separate binding makes it explicit that the acknowledgement is cleared when the reservation fails.
  • No intent or contract change; no manifest or lockfile change, so no dependency pruning applies.

Not changed: a dropped channel whose pending acknowledgement never gets room waits until the Authority closes or the connection drops, as before; bounding it would add a liveness rule.

Note

LLM-assisted content (no human feedback).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the change addressing Agent channel stalls under outbound backpressure.

No open issues 🎉

What changed in this PR

Fixes an Agent channel stall where an acknowledgement waiting for outbound capacity prevented the stream loop from detecting an Authority closure and reconnecting.

Changes:

  • Keeps a pending acknowledgement without blocking inbound reads.
  • Preserves acknowledgement order and prioritizes acknowledgements over reports.
  • Adds regression tests for reconnection under backpressure and acknowledgement ordering when the channel is dropped.
File Description
crates/​agent-channel-client/​src/​tests/​mod.rs Adds tests for closure detection with a pending acknowledgement and ordered acknowledgement delivery during shutdown.
crates/​agent-channel-client/​src/​stream.rs Sends pending acknowledgements through a selectable capacity reservation so inbound reads can continue.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants