Skip to content

Agents: unify tool reliability primitives and add boundary coverage#171

Merged
dgarson merged 1 commit intostephan/tool-reliability-layerfrom
codex/address-pr-concerns-and-report-additional-bugs
Feb 24, 2026
Merged

Agents: unify tool reliability primitives and add boundary coverage#171
dgarson merged 1 commit intostephan/tool-reliability-layerfrom
codex/address-pr-concerns-and-report-additional-bugs

Conversation

@dgarson
Copy link
Owner

@dgarson dgarson commented Feb 24, 2026

Motivation

  • Consolidate reliability logic so agent-facing code uses a single shared implementation to avoid duplication and ownership ambiguity.
  • Cover missing boundary cases in idempotency, retry, and circuit-breaker behavior to increase confidence in tool reliability primitives.
  • Remove unrelated UX topology doc that was mistakenly included in the scope of these changes.

Description

  • Route src/agents/tool-reliability.ts through the shared utilities in src/utils by using src/utils/circuit-breaker.ts and src/utils/idempotency.ts, turning the agent module into a thin adapter that adds logging and naming ergonomics.
  • Add idempotency coverage in src/utils/idempotency.test.ts to verify failed-entry TTL expiry and successful re-execution after expiry.
  • Add retry-policy boundary tests in src/utils/retry-policy.test.ts to assert jitter bounds and exponential clamping to maxDelayMs.
  • Add circuit-breaker state-transition tests in src/utils/circuit-breaker.test.ts to exercise CLOSED→OPEN behavior, OPEN cooldown recovery, and HALF_OPEN failure reopening.
  • Remove the unrelated file apps/web/ux-opus-design/AGENT-TOPOLOGY-SPEC.md from this PR to keep scope focused.

Testing

  • Ran unit tests: pnpm vitest run src/utils/idempotency.test.ts src/utils/retry-policy.test.ts src/utils/circuit-breaker.test.ts src/agents/tool-reliability.test.ts and all tests passed (4 files, 11 tests).
  • Ran pnpm check; it reported a formatting issue in src/gateway/hitl-request-store.ts that is pre-existing and outside this change set (format checks otherwise pass for files touched by this PR).

Codex Task

@dgarson dgarson merged commit ff4449a into stephan/tool-reliability-layer Feb 24, 2026
2 of 10 checks passed
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9437a4d71d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

this.store = new InMemoryIdempotencyStore({
pendingTtlMs: config.ttlMs,
completedTtlMs: config.ttlMs,
failedTtlMs: config.ttlMs,

Choose a reason for hiding this comment

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

P1 Badge Avoid caching failed idempotent executions by default

Setting failedTtlMs to ttlMs changes IdempotencyGuard semantics from “cache successes only” to “cache errors too”, so a transient failure on a key now blocks all retries with that key until TTL expiry instead of re-running the action immediately. In the agent/tool-call path this can turn short-lived backend glitches into deterministic repeated failures for the entire TTL window, which is a functional regression from the previous implementation.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant