Skip to content

Fix agent examples: top-level await, broken assertion, silent failures - #141

Merged
NicholasDCole merged 1 commit into
mainfrom
fix/agent-example-smoke-fixes
Jul 28, 2026
Merged

Fix agent examples: top-level await, broken assertion, silent failures#141
NicholasDCole merged 1 commit into
mainfrom
fix/agent-example-smoke-fixes

Conversation

@NicholasDCole

Copy link
Copy Markdown
Contributor

Summary

A full smoke sweep of all 116 examples/agents/ files against a local Conductor OSS 3.32.0-rc.8 server surfaced three groups of broken examples. This PR fixes the ones that are unambiguously example bugs (SDK/server-level findings are tracked separately).

1. Top-level await — examples didn't compile (7 files)

12-long-running, 57-plan-dry-run, 63-deploy, 63b-serve, 63c-run-by-name, 63d-serve-from-package, 63e-run-monitoring

Upstream agentspan was ESM; under this repo's CJS module flavor, tsx rejects top-level await, so these examples failed with a TransformError before running anything. All are now wrapped in the house-style async main(). 63-deploy and 63d additionally get a require.main === module guard because 63c/63e import their agent definitions — without the guard, importing would execute the sibling example.

2. Broken assertion (1 file)

74-cli-error-output called String(result.output) on an object, always producing [object Object], so its self-check false-failed even though the agent surfaced the CLI stderr correctly. Fixed to stringify properly. The same latent String(result.output) bug in 10-guardrails' PII-leak check is fixed too (it made the leak check vacuous).

3. Silent failures — printed [FAIL], exited 0 (2 files)

10-guardrails and 54-software-bug-assistant printed FAILED results but exited 0, so any exit-code-based harness passes vacuously. Both now set exit code 1 when the run ends non-COMPLETED, and their main().catch sets the exit code instead of swallowing the error.

Verification (local Conductor OSS 3.32.0-rc.8 boot JAR, Anthropic Haiku 4.5)

  • All 7 top-level-await examples + 74 run green end-to-end (exit 0, 74 prints PASS)
  • 10 and 54 now exit 1 with the real upstream diagnostics:
    • 10: server-side ChatMessage.message String-vs-Array deserialization error
    • 54: MCP server rejects credential — "Authorization header is badly formatted"
      (both are SDK/server-level issues, not fixed here)
  • npx tsc --noEmit -p examples/agents/tsconfig.json clean (one pre-existing, unrelated error in src/sdk/.../getUndiciHttp2FetchFn.ts)
  • npx eslint clean on all 10 files

🤖 Generated with Claude Code

Found by a full smoke sweep of all 116 agent examples against a local
Conductor OSS 3.32.0-rc.8 server (Anthropic Haiku 4.5).

Three groups of fixes:

1. Top-level await (7 files: 12, 57, 63, 63b, 63c, 63d, 63e): upstream
   agentspan was ESM; this repo's CJS module flavor makes tsx reject
   top-level await, so these examples did not compile at all. Wrapped in
   the house-style async main(). 63-deploy and 63d get a
   require.main === module guard because 63c/63e import their agent
   definitions - without it, importing would execute the sibling example.

2. 74-cli-error-output: the assertion did String(result.output) on an
   object, always producing "[object Object]" and false-failing even
   though the agent surfaced stderr correctly. Stringify properly.
   Same latent bug fixed in 10-guardrails' PII leak check.

3. Silent failures (10-guardrails, 54-software-bug-assistant): both
   printed [FAIL] results and exited 0, so any harness built on exit
   codes passes vacuously. They now set exit code 1 when the run ends
   non-COMPLETED (and 10-guardrails also when PII leaks); main().catch
   sets the exit code instead of swallowing errors.

Verified: all 7 TLA examples + 74 run green end-to-end against the local
stack; 10 and 54 now exit 1 with the real upstream diagnostics (a server
ChatMessage deserialization bug and an MCP Authorization-header issue,
tracked separately).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
integration-v4-sm 41.53% <ø> (ø)
integration-v5-sdkdev 43.98% <ø> (+0.06%) ⬆️
unit 73.84% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1 file 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.

@NicholasDCole
NicholasDCole merged commit c972ef9 into main Jul 28, 2026
49 of 52 checks passed
@NicholasDCole
NicholasDCole deleted the fix/agent-example-smoke-fixes branch July 28, 2026 20:42
ambiorix2099 added a commit that referenced this pull request Jul 29, 2026
main advanced four commits while this branch was in flight (#141, #142
touched agent examples). Two files gained AGENTSPAN_* references after the
rename sweep had already run, so they still told readers to set the
deprecated names:

  - SDK_DEVELOPMENT.md:623
  - examples/README.md:51-52

Both are outside the `README.md docs` scope the new CI grep covers, so
they would not have been caught. Worth noting the grep itself is correctly
calibrated: it matches AGENTSPAN_[A-Z] (a concrete variable name) and so
does not fire on the `AGENTSPAN_*` glob that the migration and reference
pages legitimately use.

Also resolves the rebase conflict in examples/agents/README.md, taking
main's table shape from #142 (example counts removed) with this branch's
"Conductor Quickstart" rename applied. The `agentspan deploy` CLI
invocation in that file is left as-is -- external command surface.

Re-verified post-rebase: lint 0 errors (358 warnings, unchanged), 1582
unit tests across 80 suites, lychee 508 links / 0 errors, schema verifier
green, 649 internal markdown links resolve.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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