Skip to content

fix: rate limiter retry counting + stub agents use AgentError#77

Merged
telivity-otaip merged 1 commit into
mainfrom
fix/rate-limiter-and-error-types
Apr 18, 2026
Merged

fix: rate limiter retry counting + stub agents use AgentError#77
telivity-otaip merged 1 commit into
mainfrom
fix/rate-limiter-and-error-types

Conversation

@telivity-otaip
Copy link
Copy Markdown
Collaborator

Summary

Codex review MEDIUM #1 + MEDIUM #4.

MEDIUM #1 — booking/api-abstraction rate limiter undercounted retries

The rate-limit counter incremented once per `execute()` call, before the retry loop. Each retry fired `requestHandler` again without incrementing the counter, under-reporting upstream traffic against provider quotas.

Fix: move the increment inside the retry loop, before each `requestHandler` call. The rate-limit guard also moves inside the loop so an attempt that would exceed the quota short-circuits cleanly without burning another outbound request.

New test verifies: 1 initial attempt + 2 retries on a retryable failure → `request_count` ends at 3 (not 1).

MEDIUM #4 — stub agents threw raw `Error`

  • New `@otaip/core` class `UnimplementedDomainInputError(agentId, detail)` with code `UNIMPLEMENTED_DOMAIN_INPUT`.
  • 4 stub agents now throw it instead of raw `Error`:
    • `DisruptionResponseAgent` (5.4)
    • `DynamicPricingAgent` (2.6)
    • `RevenueManagementAgent` (2.7)
    • `InterlineSettlementAgent` (7.4)
  • The other "placeholder" agents called out in the original Codex finding (`self-service-rebooking`, `waitlist-management`) were since fully built out and no longer throw raw Errors.
  • Tests updated to assert `toBeInstanceOf(UnimplementedDomainInputError)` plus `agentId` + `code`.

Test plan

  • `pnpm install --frozen-lockfile` — succeeds
  • `pnpm -r run typecheck` — clean
  • `pnpm run lint` — clean
  • `pnpm test` — 3,085 passed (3 skipped)

🤖 Generated with Claude Code

…omainInputError

Codex review MEDIUM #1 + MEDIUM #4.

MEDIUM #1 — booking/api-abstraction rate limiter undercounting
- Previously the rate-limit counter incremented once per execute() call,
  before the retry loop. Each retry to the upstream provider therefore
  went uncounted, under-reporting traffic against provider quotas and
  letting agents sail past per-window limits while believing they were
  still in budget.
- Move the increment INSIDE the retry loop, before each requestHandler
  call. Move the rate-limit guard inside the loop too, so an attempt
  that would exceed the quota short-circuits cleanly without burning
  another outbound request.
- New test: 1 initial + 2 retries on a retryable failure → request_count
  ends at 3, not 1.

MEDIUM #4 — stub agents throw raw Error
- New @otaip/core class UnimplementedDomainInputError(agentId, detail)
  with code 'UNIMPLEMENTED_DOMAIN_INPUT'. Callers can catch by class
  instead of string-matching.
- Replace `throw new Error(...)` in 4 stub agents with
  `throw new UnimplementedDomainInputError(...)`:
    DisruptionResponseAgent (5.4)
    DynamicPricingAgent (2.6)
    RevenueManagementAgent (2.7)
    InterlineSettlementAgent (7.4)
- Tests updated to assert on the typed error (instance + agentId + code).
- The other 'placeholder' agents called out in the original review
  (self-service-rebooking, waitlist-management) were since fully built
  out and no longer throw raw Errors.

Verification: 3,085 tests pass, lint + typecheck clean.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@telivity-otaip telivity-otaip merged commit 0bc8517 into main Apr 18, 2026
1 check passed
@telivity-otaip telivity-otaip deleted the fix/rate-limiter-and-error-types branch April 18, 2026 20:56
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