Skip to content

fix(session): retry a transcript turn cloud refuses for a moment, instead of dropping it - #18

Merged
zeekay merged 2 commits into
mainfrom
fix/event-once
Nov 27, 2026
Merged

zeekay merged 2 commits into
mainfrom
fix/event-once

Conversation

@jamessburnss1313-dev

Copy link
Copy Markdown
Contributor

What happened

A Hanzo Dev run printed warning: stream event dropped: 503: Request could not be securely recorded and the turn was lost from the session's transcript.

Cloud's audit trail refuses a write it cannot record first (503 audit_unavailable, nothing applied). The event append was tried once, so the turn was dropped.

The fix

hanzo-client already has one retry policy: a POST is repeated after a 5xx only when it names itself with a requestId, which the platform answers once. The event append now names itself, so a refused turn is made again under the same id.

The stream forwards each turn in line with reading the agent, so those tries hold the agent's output while they wait. A cloud that stays down is therefore waited on once: after a turn is lost the next ones go unnamed (one try, as before) until one lands.

Ship order

Merge and deploy hanzo-inc/cloud fix/event-once first. Today's cloud accepts requestId on this route and ignores it (verified: 201 with the field, no dedupe), so a repeat after a 5xx that did apply would store the turn twice. The cloud change stores a named turn once.

Testing

  • cargo test: 386 library tests and the integration suites pass.
  • cargo clippy --all-targets -- -D warnings: clean.
  • New tests, each seen failing before the change: a_refused_event_is_made_again_under_the_same_request_id, each_event_names_itself_apart, a_cloud_that_stays_down_is_waited_on_once.
  • Run on macOS arm64 only.

Risk

A turn refused with a 5xx now waits the wire's backoff (about 1 s, 2 s, 4 s) before the next turn is read; bounded to one turn per outage.

How to revert

Revert the one commit.

Not in this PR

The link the run prints (https://hanzo.ai/tabs/<session id>) lands on the Tabs landing page: Tabs has no route for a session id. Left for a separate change.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-27T02:49:41.667636Z
We couldn’t complete this review. Comment @codex review to try again.
af5714d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

zeekay commented Nov 27, 2026

Copy link
Copy Markdown
Member

Maintainer follow-up: New transcript retry fix: hold until cloud event-once is deployed and proven idempotent. Add regression for lost ACK/503, duplicate suppression, persistent outage and ordering/recovery; CI 45930604975 still running.

zeekay commented Nov 27, 2026

Copy link
Copy Markdown
Member

Backend dependency now tracked in hanzo-inc/cloud#1043 (existing fix/event-once branch). Hold Gen retry until backend durable dedupe ships; do not enable auto-merge ahead of deployment.

jamessburnss1313-dev added a commit that referenced this pull request Nov 27, 2026
Review of #18 asked for ordering and recovery across a refusal. The
stream forwards each turn in line, so a turn refused with a 503 is made again
under its own requestId before the next turn is sent, and the transcript keeps
the agent's order.

Testing: turns_keep_their_order_across_a_retry passes; it fails with the
previous commit reverted (the refused turn is dropped, so the requests read
[a, b] instead of [a, a, b]). cargo test: 387 lib tests and the integration
suites pass; cargo clippy --all-targets -- -D warnings clean.
Risk: none; test only.
How to revert: git revert this commit.
@jamessburnss1313-dev

Copy link
Copy Markdown
Contributor Author

Your regression list, covered as follows:

Case Where it's covered
503 retried, not dropped a_refused_event_is_made_again_under_the_same_request_id. The repeat carries the same requestId.
Lost ACK Same path. A 5xx or a timeout after cloud applied the turn is retried under the same id, and cloud answers it with the stored turn. The server half is hanzo-inc/cloud#1043 (TestARetriedEventIsStoredOnce, byte-for-byte same answer). A timeout follows the same request.repeats() rule in hanzo-client as a 5xx; I didn't add a timeout test, because the client timeout is 30 s.
Duplicate suppression Server side, in cloud#1043: one row per id, racers included. A reused id with a different turn gets a 422.
Persistent outage a_cloud_that_stays_down_is_waited_on_once. Only one turn waits out the backoff. Later turns go unnamed, one try each, until one lands.
Ordering and recovery turns_keep_their_order_across_a_retry (new). The requests read [a (503), a, b]. Turns are named again once one lands (the persistent-outage test).

cargo test: 387 lib tests and the integration suites pass; clippy is clean.

This stays held until cloud#1043 is merged and deployed. It's left as a PR and not merged.

…ain, not dropped

A stream said "stream event dropped: 503: Request could not be securely
recorded" and the turn was lost from the session's transcript: cloud's audit
trail could not record the request, so nothing was applied, and the append was
tried once.

The wire's one retry policy (hanzo-client) repeats a POST after a 5xx only when
the request names itself with a requestId, which the platform answers once. The
event append now names itself, so a refused turn is made again under the same id.

The stream forwards each turn in line with reading the agent, so those tries hold
the agent's output while they wait. A cloud that stays down is waited on once:
after a turn is lost the next go unnamed (one try, as before) until one lands.

Needs cloud to store a repeated requestId once on
POST /v1/agents/sessions/:id/events (hanzo-inc/cloud, branch fix/event-once)
BEFORE this ships: today's cloud accepts the field and ignores it, so a repeat
after a 5xx that did apply would store the turn twice.

Testing: cargo test (386 lib tests and the integration suites pass);
cargo clippy --all-targets -- -D warnings clean. New tests failed before the
change: a_refused_event_is_made_again_under_the_same_request_id,
each_event_names_itself_apart, a_cloud_that_stays_down_is_waited_on_once.
Risk: a turn refused with a 5xx now waits up to the wire's backoff (about
1 s, 2 s, 4 s) before the next turn is read; bounded to one turn per outage.
How to revert: git revert this commit.
Review of #18 asked for ordering and recovery across a refusal. The
stream forwards each turn in line, so a turn refused with a 503 is made again
under its own requestId before the next turn is sent, and the transcript keeps
the agent's order.

Testing: turns_keep_their_order_across_a_retry passes; it fails with the
previous commit reverted (the refused turn is dropped, so the requests read
[a, b] instead of [a, a, b]). cargo test: 387 lib tests and the integration
suites pass; cargo clippy --all-targets -- -D warnings clean.
Risk: none; test only.
How to revert: git revert this commit.
@zeekay

zeekay commented Nov 27, 2026

Copy link
Copy Markdown
Member

Rebased onto main (de4c3a3) at 9dd07252:

  • Verified requestId pairing with cloud#1043 (a_refused_event_is_made_again_under_the_same_request_id, each_event_names_itself_apart, turns_keep_their_order_across_a_retry, a_cloud_that_stays_down_is_waited_on_once) and backward-compatible degradation against old Cloud servers (json.Unmarshal ignores unknown requestId).
  • cargo test --locked: 399 lib + 1 filesize + 3 signals = 403 tests passed (0 failed).
  • cargo clippy --all-targets -- -D warnings: 0 warnings.

@zeekay
zeekay merged commit ee07ce5 into main Nov 27, 2026
1 check passed
@zeekay
zeekay deleted the fix/event-once branch November 27, 2026 03:35
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