Repository navigation
feat(js): add Python and TypeScript runtime host functions - #2740
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | c145267 | Commit Preview URL Branch Preview URL |
Oct 16 2026, 08:57 PM |
2 tasks done
2 tasks done
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 changed
Node/Bun/Deno applications can register synchronous or asynchronous host functions for embedded Python and TypeScript on Bash, BashTool, and all JavaScript agent adapters. Each execution preserves its caller's AsyncLocalStorage context and supplies an AbortSignal for host I/O. Reset preserves handlers; snapshot restoration accepts fresh callbacks.
Blocking instance access rejects active asynchronous execution, preventing event-loop deadlocks involving host functions, streaming output, and live filesystem handles. Added bounded JSON conversion and explicit callback rows to the capability parity contract; Rust BashTool gains the Python callback builder counterpart.
Why
Extend the shipped Python integration to the native JavaScript SDK and make cross-surface callback gaps explicit. Browser/WASM and C follow in separate PRs.
Before / After
Before: externalFunctions had no callable JavaScript dispatcher; TypeScript runtime options were unavailable. LangChain used synchronous execution internally.
After: Python lookup(21, multiplier=2) and TypeScript await double(21) return 42 through real host callbacks. Local verification: 656 AVA tests and 167 runtime compatibility tests pass, including HTTP request contexts, queued requests, cancellation, timeout/reuse, snapshots, recursive access, worker-thread environments and all agent adapters. A subprocess regression terminates workers with pending or CPU-bound host functions and verifies quiet native teardown; completed ScriptedTool worker shutdown is also covered. Shared JSON codec and Rust tool callback tests pass. CI adds targeted macOS/Windows callback coverage alongside the existing Linux Node/Bun/Deno matrix.
just pre-pr,just test, all-target/all-feature Clippy and the parallel execution benchmark pass locally.Risk
Medium: native callback lifetime and synchronization. Execution-local revocation, weak NAPI dispatchers, bounded queues and blocking-entry guards cover shutdown/cancellation/reentry. Host I/O must observe its signal; application side effects cannot be rolled back.
Checklist