Repository navigation
Show and tell: a runnable OpenRouter server-tool completion-boundary comparison #1808
canblmz1
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I maintain prefix-safe-json (PSJ). I built a small TanStack AI / OpenRouter comparison for applications that want original stream completion evidence before a server tool records a side effect.
The example runs real
chat()server tools and the installed HTTP/SSE parsers with@tanstack/ai@0.69.0,@tanstack/ai-openrouter@0.22.0,@openrouter/sdk@0.13.20, Zod4.6.5and PSJ0.5.4. The SQL-shaped input is only recorded in memory.lengthterminationThe optional guarded wrapper waits for a tee of the original HTTP evidence, binds the decision to the execution context's
toolCallId, and consumes authority once before the counter changes. The test also checks the paired result sent to the next model request and the final streamed response. It covers one call per response.To try it with Node 22+ and npm, download the source-only trial ZIP, extract it, and run:
No API key, live model request, repository clone or PSJ build is needed. The launcher retains the independent npm project for editing. For a PSJ-free native baseline before adding the optional comparison, the standalone gist provides both paths.
The malformed-input fallback is already removed in pinned upstream source; I did not build or run all of upstream main. That correction is useful independently of PSJ. The complete-JSON/output-limit cases test an optional caller policy, not production frequency or a requirement for every application. This investigation also found two bugs in PSJ's own
0.5.3OpenRouter adapter;0.5.4fixes them.These are selected authored mock-transport checks. Production transport interception needs cancellation, timeouts and bounded buffering; application authorization, semantic validation and durable side effects remain caller-owned.
If you have a SQL or file tool where this boundary would help, I'd welcome a harmless complete/interrupted counter test in your own project. Reply with versions and the outcome or a concrete blocker; I'm happy to help connect the original evidence to your actual execution boundary.
All reactions