llm.chatdemo function (examples/demo_app.py) - the AI node of the agent-orchestration experiment E0: a provider-neutral LLM adapter (Anthropic and Gemini backends behind one contract; select withllm.providerconfig /-Dllm.provider=.../params.provider) with structured output (schema-> JSON verdicts for graph decision routing; additionalProperties defaults closed), usage/stop_reason surfacing, provider-error mapping onto the envelope status, and the params.timeout_ms time-budget mapping. The SDKs are an optional extra (pip install "mercury-composable[llm]"); the package itself stays SDK-free (scope fence intact).llm.streamdemo function - the STREAMING AI node: pulls the provider's real token stream (Anthropicmessages.streamor Geminigenerate_content_stream) and relays each token batch over the multi-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; provider errors fail the stream in-band. Live-proven end to end with real Gemini tokens (2026-08-31).
The progressive-rendering milestone release. The version aligns with the Mercury Composable engine lock-step line (Java and Rust engines, Python and Node.js language packs all at v4.12.0): token/event streaming end to end with full OpenTelemetry lineage, business-correlation continuity and application log context across all four runtimes - useful on its own, and the foundation for the AI SDLC (agent, MCP and tool adapters as wrapper-side functions with complete observability).
- Event streaming - the platform-wide multi-shot reply contract, both halves.
Producer:
@preload(..., interceptor=True)handlers receive the raw envelope and stream throughEventStreamWriter(the engines' exact API -first,write,write_named,closewith trailing metadata,failwith the standard error key-values); the/api/eventhost answers a caller that acceptstext/event-streamwith the platform's hybrid SSE dialect (envelope frames for the head, the terminals and non-text segments; raw frames for text tokens), refuses a non-accepting caller of a streaming function with the pinned 406, and keeps single-shot replies over the capable path byte-identical. Consumer:PostOffice.stream()(an async iterator yielding the same decoded envelopes an engine reply route receives, with the dialect conformance guards) andPostOffice.stream_to()(the relay form: forward your caller's reply address and segments flow through verbatim - engine-parity composition). Under it all, the primitive event bus gained the engines' reply_to mechanism: envelope-routed delivery to a LOCAL function or per-request reply sink - simple routing, no orchestration. Same keep-alive config key as the engines (event.stream.keep.alive). Engine-identical wire and messages (Java PR #299-#301 / Rust PR #216-#218 lineage). - Business correlation-id continuity (the engines' PostOffice parity): the
client stamps the current context's business correlation-id onto outbound
events as the engine-managed
my_cidtag, local bus deliveries inject the read-onlymy_correlation_idheader view exactly like the HTTP host, andget_trace()/trace_context()carrymy_correlation_id- so the business correlation-id continues across engine⇄wrapper and wrapper⇄wrapper hops. - Span lineage (the engines' telemetry model): every traced execution mints
a 16-hex span with the caller's span (from the inbound envelope) as its
parent, outbound events carry the current span so the next hop parents onto
it (
PostOffice.touchparity, W3Ctraceparentincluded), streaming segments carry the producer's span, and non-RPC executions emit the engines' distributed-trace dataset record on thedistributed.tracinglog stream - the same{"trace": {...}, "annotations": {...}}shape the Java engine logs, so stdout log-ingest agents stitch spans across all four runtimes. RPC round-trips are suppressed exactly like the engines (the newrpcenvelope tag ridesrequest()calls).trace_context()acceptsspan_idto parent onto an external OpenTelemetry span. Outbound events and stream segments also fill their sender with the executing function's route, and the/api/eventhost fillsevent.api.servicefor an anonymous caller - the engines' sender-attribution rules. - Application log context (the engines' app-log-context feature, on by
default via the packaged
default-log-context.yaml- the engines' resource twin): withlog.formatjson/compact, every log line inside a traced request carries acontextblock - cid (the business correlation-id), traceId, tracePath, spanId, parentSpanId, service, timestamp - so app logs and the distributed-trace records correlate end to end. Customize withresources/app-log-context.yaml(reserved$tokensor constants with${ENV:default}), opt out withapp.log.context=false, and add per-request key-values withupdate_context()(reserved keys guarded). - Documentation site (mkdocs-material, the engine repo's theme): the three-layer theme reference, rationale/design foundations, function-writing patterns, flow and knowledge-graph join chapters, a one-page AI agent guide with llms.txt, and configuration/HTTP references - published to https://accenture.github.io/mercury-python/ by the new CI workflow, which also runs the three quality gates (pytest, ruff, basedpyright) on every push and pull request.
- Host polish for engine parity:
GET /serves the engines' minimal index page linking the actuator endpoints (embedded - no static file service by design); actuator JSON responses are pretty-printed (the engines' default-serializer presentation); unknown paths and non-GET methods answer the engines' error shape{"status": 404, "message": "Resource not found", "type": "error"}. - Sync bridge:
PostOffice.request_sync()/send_sync()let a plaindefhandler (the synchronous ecosystem -requests, NumPy/ML inference, database drivers) call sibling or remote functions - the call runs on the host event loop while only the handler's worker thread blocks; the trace chain rides across unbroken. Calling the bridge from async code, or outside a hosted function, is refused with a teaching error. The sync-vs-async handler rationale is now documented (README and the registry module). - Actuator endpoints
/info,/info/routes,/env,/healthand/livenessprobe- the engines' operational surface, for Kubernetes probes and one-dashboard monitoring of polyglot installations. Health check functions are normal registered functions speaking the engines'type=info/type=healthinterface contract, listed inmandatory.health.dependencies/optional.health.dependenciesand called through the event bus./healthanswersUP(200) /DOWN(400);/livenessprobefollows the most recent health outcome. log.formatcarries the engines' three presentations:text(default),json(pretty-printed) andcompact(single-line JSONL for log aggregators). A sampleexamples/resources/application.ymldemonstrates the resources convention and the well-known keys.- Primitive in-process event bus - the single dispatch pipeline: one FIFO mailbox per
route consumed by
instancesworker tasks (the parameter is faithful); RPC deliveries are ttl-bounded with a dead-work skip; drop-n-forget returns the 202-shape ack. The HTTP host and the local side of PostOffice are thin ingress adapters over it. No spill tier and no queue cap by design - back-pressure belongs to the engines' flows/graphs; a leaf host fails fast by deadline. - PostOffice without an endpoint delivers locally (engine semantics): private routes are callable in-app while the wire keeps its 403; headers pass verbatim; the reply envelope shape is identical to the remote path.
Repository repurposed for the Mercury Composable polyglot initiative (August 2026).
- Lightweight Event-over-HTTP function host (
POST /api/event) mirroring the engines' EventApiService semantics (x-ttl execution bound, x-async drop-n-forget with 202 ack, reserved header hygiene,my_cid→my_correlation_idinjection, portable error contract, engine-identical error messages). - Standard event envelope wire format codec, verified against the golden conformance vectors shared with the Java and Rust engines; compact format detected and rejected.
@preloadfunction registry with instance-count concurrency limits and private routes.PostOfficethin client with the engines' relay HTTP contract (octet-stream, x-ttl, x-no-stream, trace headers) for calling engine or peer polyglot functions.- Minimalist utilities in engine-consistent style:
AppConfig(${ENV:default}substitution, runtime overrides), logging in the reference log4j2 presentation (log.format=text|json,LOG_LEVEL), and distributed-trace context with reply annotations. mercury-servedeveloper runner.
The legacy Mercury language-pack implementation (pre-composable, websocket-based) remains available in the git history prior to this version.