Skip to content

fix(client): reset connection_failures when a store that gave up is started again - #139

Merged
XieX merged 2 commits into
xie/agent-skillsfrom
xie/skills-restart-resets-counter
Oct 6, 2026
Merged

XieX merged 2 commits into
xie/agent-skillsfrom
xie/skills-restart-resets-counter

Conversation

@XieX

@XieX XieX commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR

After a store gives up and you call start() again, diagnostics.connection_failures kept the old run's count. So a healthy restarted store looked like it was already in an outage. This is a one-line fix, and it matches the TypeScript SDK. Found in review of https://github.com/launchdarkly/ai-sdks-monorepo/pull/40#pullrequestreview-5419525312.

Changes

  • _rearm_waiters resets diagnostics.connection_failures, alongside the internal _failures count it already reset. Before this, two recoverable failures and then a 401, followed by start(), gave failed is None and connection_failures == 2, with nothing failed in the new run. TypeScript resets the counter in start() (js-ai-sdk#107).
  • New test test_a_restart_reports_no_failures_before_the_new_run_has_any. It holds the new run's first request open and reads the counter right after start(). The existing test_a_restart_resets_the_failure_count couldn't catch this, because it reads the counter only after the new run fails, and that failure overwrites the stale value. The new test fails with 2 == 0 when the reset is reverted.
  • README (recovery after a 422) and agents.md now say the counter resets on restart.
  • The wait_for_skills docstring now says a store that gave up waits again once start() runs, and only close is final. Same change for TypeScript: docs(client): say a restarted store's waitForSkills waits again js-ai-sdk#113.

Spec: TESTING.md §3.25 in https://github.com/launchdarkly/ai-sdks-monorepo/pull/40.

Test plan

  • make lint, make format-check, make typecheck
  • make test: 2201 passed, 11 skipped
  • New test fails with the fix reverted
  • Note: TestWatchSkillsOverTheTransport::test_a_revocation_prunes_without_a_restart failed once in my runs. It also fails on xie/agent-skills without this change (1 in 25 runs), so it's an existing flaky test.

🤖 Generated with Claude Code

…tarted again

`_rearm_waiters` reset the internal `_failures` count but not
`diagnostics.connection_failures`, so a restarted store reported the old
run's failures until its new run failed or succeeded: after two
recoverable failures and a 401, `start()` left `failed` None with
`connection_failures == 2` and nothing failed in the new run. That
counter is the outage signal now that recoverable failures retry
indefinitely, so a healthy restart read as a store already riding out
an outage. The TypeScript SDK resets it in `start()`.

`test_a_restart_resets_the_failure_count` could not see this: it reads
the counter only after the new run's first failure, which overwrites
the stale value. The new test holds the new run's first request open
and reads the counter right after `start()`; it fails with `2 == 0`
when the reset is reverted.

Spec: launchdarkly/ai-sdks-monorepo#40 (TESTING.md §3.25).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XieX
XieX requested a review from jeffdupont October 5, 2026 19:43
@jeffdupont jeffdupont mentioned this pull request Oct 5, 2026
The docstring listed a give-up as ending delivery with no hint that
start() undoes it. Matches TESTING.md §3.25 (ai-sdks-monorepo#40).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@XieX
XieX merged commit 805178f into xie/agent-skills Oct 6, 2026
7 checks passed
@XieX
XieX deleted the xie/skills-restart-resets-counter branch October 6, 2026 14: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