Skip to content

feat(loops): injectable completion transport on the worker seam — offline without a mock server#380

Merged
drewstone merged 1 commit into
mainfrom
feat/completion-transport-on-worker-seam
Jun 24, 2026
Merged

feat(loops): injectable completion transport on the worker seam — offline without a mock server#380
drewstone merged 1 commit into
mainfrom
feat/completion-transport-on-worker-seam

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

What

Adds an optional completion transport to the worker seam so benchmarks/agentic runs go fully offline with zero credentials and no localhost server.

RouterConfig gains an optional complete?: (body) => Promise<unknown>. When set, routerChatWithUsage and routerChatWithTools call it with the OpenAI request body and parse the /chat/completions JSON it returns, instead of fetch-ing the router. When absent, the existing fetch path runs unchanged — the live router stays the default, so this is additive with no breaking change.

It is threaded through AgenticOptions → the worker's routerToolLoop cfg, and the analyst's ChatClient is bound to the same injected transport (via agent-eval's mock transport). One injected responder therefore serves both legs of an offline run — the worker's tool-calling turns and the refine/doubleCheck analyst's chat-only steer — exactly as a localhost mock endpoint used to.

Why

examples/strategy-suite previously needed a ~106-line in-process localhost HTTP server (mock-router.ts) just to run offline. The real boundary the worker needs is a single chat-completions call — so make THAT injectable, the same grain ToolLoopChat and agent-eval's ChatClient already use, and the server disappears.

Changes

  • src/runtime/router-client.tsRouterConfig.complete; routerChatWithUsage / routerChatWithTools short-circuit fetch when it is set.
  • src/runtime/strategy.tsAgenticOptions.complete, threaded into the worker loop; new internal analystChat() binds the critic to the same transport when injected.
  • src/runtime/router-client.complete.test.ts — locks the contract (uses complete, never fetch; absent ⇒ fetch unchanged).
  • examples/strategy-suite/ — rewired to inject a deterministic complete fn; deletes mock-router.ts (106 LOC server); README updated. Live router (TANGLE_API_KEY) stays the drop-in upgrade.

Verify (local)

  • pnpm run typecheck (src + examples), pnpm run build, pnpm run lint, pnpm run docs:check — all green.
  • pnpm test — 116 files, 1123 passed, 2 skipped, 0 failed (incl. 3 new seam tests).
  • Ran strategy-suite offline (no TANGLE_API_KEY) with no mock-router.ts: prints the full leaderboard (sample / refine / doubleCheck all 100% resolved).
  • grep confirms 0 references to the deleted mock-router remain.
  • Merges cleanly into origin/main (git merge-tree exit 0).

…line without a mock server

Add an optional `complete?: (body) => Promise<unknown>` transport to `RouterConfig`,
consumed by `routerChatWithUsage` + `routerChatWithTools` instead of fetching the router
when present. When absent the fetch path runs unchanged — the live router stays the default,
zero breaking change. Threaded through `AgenticOptions` → the worker's `routerToolLoop` cfg,
and bound to the analyst's `ChatClient` (via agent-eval's mock transport) so one injected
responder serves BOTH legs of an offline run, exactly as a localhost endpoint would.

Rewires examples/strategy-suite to run fully offline by injecting a deterministic `complete`
fn and deletes examples/strategy-suite/mock-router.ts (the ~106-line localhost HTTP server).
The live router (TANGLE_API_KEY present) remains the drop-in upgrade.

@tangletools tangletools left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Auto-approved PR — e3ee0b7f

Blanket team auto-approval is enabled for this reviewer service.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.

tangletools · auto-approval · reason: blanket_auto_approve · 2026-06-24T18:09:56Z

@drewstone drewstone merged commit 2910bbf into main Jun 24, 2026
1 check passed
drewstone added a commit that referenced this pull request Jun 24, 2026
…ransport seam (#382)

Publish the merged #379 (inProcessSandboxClient) and #380 (injectable
completion transport on the worker seam) substrate exports. Bump version
0.76.0 -> 0.77.0 and refresh the generated primitive-catalog version stamp.
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