fix(chat): complete streaming for reasoning, tools, and tool calls

- Forward reasoning_content and non-stream reasoning to on_token in
  OpenAI chat completions; Gemini thought parts to on_token.
- Stream bubble: always render session.tool panels; format tool_use_call
  payloads and title as call · tool_name.
- Emit tool_use_call via on_tool_ui before tool execution so WS shows
  invoke cards before tool_use_result.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-10 14:02:14 +08:00
parent 75a3038f33
commit 398d85ba06
4 changed files with 68 additions and 17 deletions

View file

@ -1354,6 +1354,22 @@ def run_oclaw_direct_loop(
# force one no-tool synthesis pass to guarantee a visible assistant body.
hit_tool_round_limit = True
# Stream UI: emit one session.tool per pending call before execution (tool_use_result fires after).
if callable(on_tool_ui):
for tc in step.llm_tool_calls:
try:
on_tool_ui(
"tool_use_call",
{
"phase": "call",
"tool_name": str(getattr(tc, "name", "") or ""),
"tool_call_id": str(getattr(tc, "id", "") or ""),
"arguments": dict(getattr(tc, "arguments", {}) or {}),
},
)
except Exception:
pass
elapsed_ms, results_by_id = _execute_tool_step(
skill_exec=skill_exec,
store=store,