AI nodes llm.chat and llm.stream - provider-neutral LLM adapters (E0) - #22
Merged
Conversation
The agent-orchestration experiment's wrapper-side AI nodes: llm.chat answers a prompt or conversation with optional schema-constrained structured output (the verdict shape a graph's decision routing needs), llm.stream relays the provider's real token stream over the multi-shot reply contract so a calling engine renders it progressively out its own HTTP edge. One contract, two provider editions (Anthropic and Gemini SDKs as lazy optional extras - pip install 'mercury-composable[llm]'); provider errors ride the envelope status; timeout_ms maps onto the SDK timeout (the x-ttl pattern); the Gemini editions opt out of the SDK's automatic-function-calling loop (no tool surface by design - the graph decides, the model advises). 14 token-free tests pin the contract with fake clients and a recording writer. Co-Authored-By: Claude Code <noreply@anthropic.com>
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
The agent-orchestration experiment's wrapper-side AI nodes in the demo app:
llm.chat: answers a prompt or conversation with optional schema-constrainedstructured output - the parseable verdict shape a graph's decision routing needs
(
additionalPropertiesdefaults to false). Returns text|data, model, stop_reason andusage; provider errors ride the envelope status (portable to a graph's error context);
params.timeout_msmaps onto the SDK timeout (the x-ttl pattern).llm.stream: pulls the provider's real token stream and relays each batch over themulti-shot reply contract, so a calling engine renders it progressively out its own HTTP
edge as SSE; terminal metadata carries model, stop_reason, usage and the trace/business
correlation ids.
(
pip install 'mercury-composable[llm]'). The Gemini editions opt out of the SDK'sautomatic-function-calling loop - these nodes expose no tool surface by design (the
graph decides, the model advises), which also silences the SDK's AFC advisory warning.
CHANGELOG updated.
Why
bp-agent-orchestration/bp-polyglot-functions: LLM adapters live on the wrappers asplain functions (the ratified scope fence - the engine stays LLM/vendor-free), so a
certified graph calls a model like any other route. Live-proven with the engine's
support-triage graph (real Gemini verdicts, one distributed trace across processes) and
the progressive streaming demo (25+ token batches through the engine's SSE edge).
Tests
97 passed; ruff and basedpyright clean.
Co-Authored-By: Claude Code noreply@anthropic.com
🤖 Generated with Claude Code