You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
phase 4.2: pre-resolve streaming mode for tool calls
new opt-in header X-Zhub-Stream-Tools: pre-resolve. when set with
stream:true, the hub runs the full non-streaming auto-resolve loop
internally (same one phase 1.8 uses), then emits the resolved final
text as a single SSE chunk + done. trades stream-latency for tool
correctness — useful when the brain may emit tool_calls and you want
the resolved answer arriving over SSE instead of as a non-stream JSON.
default streaming behavior unchanged: text chunks forwarded as SSE,
no tool resolution (matches today's path). header is purely additive.
implementation: extracted the auto-resolve body into a single helper
_run_autoresolve_loop(ai_name, ...) → (final_text, finish_reason).
both the existing non-streaming path and the new pre-resolve path call
it. zero duplication of the schema-validation + parallel-gather +
unwrap dance.
true chunked tool_call delta passthrough (where each function-args
fragment streams to the client as it arrives) is phase 4.2b — needs
brain-adapter + publisher-sdk changes to surface tool_call deltas
through the WS chat-chunk envelope shape.
tests:
- stream:true + pre-resolve header → SSE response with the AUTO-
RESOLVED text containing both the publisher's final output and the
tool result the connected handler returned (1)
- stream:true + no header → today's behavior preserved (1)
122/122 pytest now.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,8 +86,9 @@ Tests: `pytest -v`. The e2e tests spin up the hub in-process and run the full pu
86
86
-**Phase 3.0b** ✅ — `X-Zhub-Entity-Hint` header on 4xx/5xx responses pointing at `/entity/errors/<code>`. Closes the entity loop: any AI hitting an error gets a self-debug pointer.
87
87
-**Phase 4.0** ✅ — `zhub/brains/` package: `BrainAdapter` ABC + four streaming adapters (Ollama, Groq, OpenAI, Cerebras). `detect()` walks them in priority order. `examples/multi_brain_publisher.py` exposes `--brain auto|ollama|groq|openai|cerebras` so the brain underneath any zhub publisher is one CLI flag away from a swap. External clients (Pocket/Loki/curl/MCP) see no change; key stays stable across brain swaps via persistence.
88
88
-**Phase 4.1** ✅ — Entity v2: operator-extensible. `POST/GET /entity/extend` and `DELETE /entity/extend/{id}` (auth: any registered publisher's bearer key). Extensions persist in SQLite (`entity_extensions` table), surface inline in `/entity/<section>` and at the title-matched code under `/entity/errors/<code>`, and live alongside shipped recipes (shipped wins on canonical conflicts). Caps: 8KB per body, 200 per hub. Each hub now grows its own institutional memory.
89
+
-**Phase 4.2** ✅ — Pre-resolve streaming mode for tool calls. Header `X-Zhub-Stream-Tools: pre-resolve` + `stream:true` runs the full non-streaming auto-resolve loop internally, then emits the resolved final text as one SSE chunk + done. Trades stream-latency for tool-call correctness in streaming mode. The non-streaming auto-resolve loop is now a shared helper (`_run_autoresolve_loop`) used by both code paths. True per-token tool_call delta passthrough = future Phase 4.2b (needs brain-adapter + publisher-SDK changes to surface tool_call deltas).
89
90
90
-
**Next (not started):**tool streaming via SSE (Phase 1.8c — would need to detect tool_calls during stream and pause), multi-tier API keys, real ZAI integration via `zai_publish.py`.
91
+
**Next (not started):**real ZAI integration via `zai_publish.py`, multi-tier API keys, full tool_call streaming (4.2b), MCP resources/prompts surface.
0 commit comments