feat(ruby): M3 — inbound dispatcher + client-side LLMs (77/77) - #2855
Draft
filip-michalsky wants to merge 1 commit into
Draft
feat(ruby): M3 — inbound dispatcher + client-side LLMs (77/77)#2855filip-michalsky wants to merge 1 commit into
filip-michalsky wants to merge 1 commit into
Conversation
- rpc_client: dedicated dispatcher thread for inbound work; on_request API (params decoded / results validated via Models::METHODS, JSON-RPC error mapping matching Python: -32601/-32602/-32603 with error name data); notification listeners now run on the dispatcher and may issue RPC calls - client: model: accepts a callable -> registers an llm.generate handler and announces ClientModelReference(source: "client") in stagehand.init - wire: unions follow nested union references (LLMMessageContentBlock blocks decode to LLMTextContent etc. instead of raw hashes) - examples/custom_llm.rb: port of custom_llm.py over an OpenAI-compatible chat completions endpoint (OPENAI_API_KEY or Vercel AI Gateway); verified live on local Chrome and Browserbase (extract/observe/act all served by the Ruby callback) - tests: on_request round trip, handler-issued RPC calls, error mapping, removal semantics, client wiring (108 runs, 711 assertions) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
This was referenced Aug 29, 2026
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.
Part of the AP-2857 parity stack:
Stack: #2820 (spike) ← #2854 (M1–M2) ← this PR (M3) ← M4 (#2851)
The 77th and final protocol method — inbound
llm.generate:RPCClientgains a dedicated dispatcher thread for inbound work and anon_requestAPI: params decoded and results validated via the generated wire registry, JSON-RPC error mapping matching Python (-32601/-32602/-32603with the error class name as data)page.onblocks) now run on the dispatcher and may issue RPC calls (the reader-thread restriction is gone)Stagehand.create(model: ->(params) { … })registers anllm.generatehandler and announcesClientModelReference(source: "client")instagehand.initexamples/custom_llm.rb: port ofcustom_llm.pyover an OpenAI-compatible chat completions endpoint (OPENAI_API_KEY or Vercel AI Gateway)Verification
custom_llm.rbruns extract/observe/act with every model call served by the Ruby callback (4llm.generateround trips)🤖 Generated with Claude Code