feat(loops): injectable completion transport on the worker seam — offline without a mock server#380
Merged
Conversation
…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
approved these changes
Jun 24, 2026
tangletools
left a comment
Contributor
There was a problem hiding this comment.
✅ 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional completion transport to the worker seam so benchmarks/agentic runs go fully offline with zero credentials and no localhost server.
RouterConfiggains an optionalcomplete?: (body) => Promise<unknown>. When set,routerChatWithUsageandrouterChatWithToolscall it with the OpenAI request body and parse the/chat/completionsJSON it returns, instead offetch-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'srouterToolLoopcfg, and the analyst'sChatClientis bound to the same injected transport (via agent-eval'smocktransport). 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-suitepreviously needed a~106-linein-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 grainToolLoopChatand agent-eval'sChatClientalready use, and the server disappears.Changes
src/runtime/router-client.ts—RouterConfig.complete;routerChatWithUsage/routerChatWithToolsshort-circuitfetchwhen it is set.src/runtime/strategy.ts—AgenticOptions.complete, threaded into the worker loop; new internalanalystChat()binds the critic to the same transport when injected.src/runtime/router-client.complete.test.ts— locks the contract (usescomplete, neverfetch; absent ⇒ fetch unchanged).examples/strategy-suite/— rewired to inject a deterministiccompletefn; deletesmock-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).TANGLE_API_KEY) with nomock-router.ts: prints the full leaderboard (sample/refine/doubleCheckall 100% resolved).grepconfirms 0 references to the deletedmock-routerremain.origin/main(git merge-treeexit 0).