Skip to content

fix(agents): Custom guardrail worker misreports pass as fail on retry/fix - #150

Merged
kowser-orkes merged 1 commit into
mainfrom
fix/guardrail-custom-onfail-passed
Jul 29, 2026
Merged

fix(agents): Custom guardrail worker misreports pass as fail on retry/fix#150
kowser-orkes merged 1 commit into
mainfrom
fix/guardrail-custom-onfail-passed

Conversation

@kowser-orkes

Copy link
Copy Markdown
Contributor

Pull Request Title: fix(agents): custom guardrail worker misreports pass as fail on retry/fix

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • WHOSUSING.md
  • Other (please describe):

Changes in this PR

  • _registerGuardrailWorker always echoed the guardrail's configured on_fail value even when the check passed, so the server-side router (which only treats on_fail: null/"pass" as passing) always routed passing custom guardrails into the retry loop until it hit the retry ceiling and failed the whole run; now sets on_fail: "pass" on success, matching Java/Python
  • examples/agents/04-guardrails.ts used onFail: 'human' with the one-shot runtime.run() API, which hangs forever since nothing completes the pending human task; changed to onFail: 'retry', matching the same combo demo in 10-guardrails.ts

Issue #

Alternatives considered

None.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
integration-v4-sm 41.50% <0.00%> (+0.03%) ⬆️
integration-v5-sdkdev 43.91% <0.00%> (-0.17%) ⬇️
unit 73.89% <50.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/agents/runtime.ts 73.74% <100.00%> (+1.01%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kowser-orkes
kowser-orkes force-pushed the fix/guardrail-custom-onfail-passed branch from 4fbba1f to 7ca22bb Compare July 29, 2026 03:06
…/fix

_registerGuardrailWorker always echoed the guardrail's configured onFail
value in on_fail, even when the check passed. The server-side guardrail
router only treats on_fail as "pass" when it's null/"pass", so any custom
guardrail(onFail: 'retry'|'fix') that genuinely passed was still routed
into the retry loop, permanently, until it hit the workflow's retry
ceiling and failed the whole run.

Also fixes examples/agents/04-guardrails.ts's factChecker, which used
onFail:'human' with the one-shot runtime.run() API -- a real hang, since
nothing ever completes the pending human task in that script. Matches
the onFail:'retry' pattern already used by the equivalent guardrail-type
combo demo (10-guardrails.ts); onFail:'human' has its own dedicated demo
in 32-human-guardrail.ts using the correct start/stream/respond pattern.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@kowser-orkes
kowser-orkes force-pushed the fix/guardrail-custom-onfail-passed branch from 7ca22bb to 500a5e6 Compare July 29, 2026 04:11
@kowser-orkes
kowser-orkes merged commit 535056f into main Jul 29, 2026
25 of 27 checks passed
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