Skip to content

fix(dashboard-api): recognize reasoning tokens and tool calls in pixel chat stream - #5607

Open
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-chat-reasoning-answer
Open

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-chat-reasoning-answer

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/extensions/services/dashboard-api/routers/pixel.py, the retained chat stream handler _produce_retained_result() monitors Server-Sent Events (SSE) from the Pixel edge service to determine whether a response contains meaningful output before saving it into ChatResultStore. Lines 780-783 evaluate answer_seen by strictly checking if isinstance(payload, dict) and isinstance(payload.get("content"), str) and payload["content"]: answer_seen = True. When using reasoning models (such as DeepSeek-R1 distillations, Qwen reasoning checkpoints, or models emitting thought traces) or tool-calling models, generated tokens are streamed in reasoning_content (or tool_calls) while content remains empty or omitted. Because answer_seen remains False, the arrival of data: [DONE] (lines 784-794) misclassifies the completed response as an aborted/zero-output session, flags failed = True, and overwrites the user transcript with an error frame: "Pixel returned no answer. Try again.".

This fix surgically expands the stream content probe in _produce_retained_result() to set answer_seen = True when payload contains non-empty reasoning_content or tool_calls. Genuine zero-token aborts (such as premature cancellations or role-only frames) remain rejected as empty, while reasoning streams and tool executions complete successfully. Existing receipts persistence, ownership boundaries, and stream timeouts remain untouched.

Validation

  • Baseline reproduction: Upstream SSE streams emitting reasoning_content chunks followed by data: [DONE] evaluated answer_seen as False, marking the session state as interrupted and appending "Pixel returned no answer. Try again.".
  • Post-fix behavior: Upstream streams emitting reasoning_content or tool_calls resolve cleanly to state complete without injecting false errors, while role-only streams without tokens continue to be flagged as interrupted.
  • Telemetry statement: "[Dashboard-api] suites: 3 passed. New-test Ruff, ShellCheck, and diff checks pass; new regressions wired into Linux CI."

Overlap check

Risk / AI disclosure

AI-assisted investigation, implementation and CLI regressions. This strengthens SSE stream payload accounting for reasoning models, not runtime admission. Independent human review and platform/runtime qualification remain gates. No running configuration, deployment or upstream merge changed.

Follow-up integration evidence

Composed with #5606 at ebe8577 without conflicts. Production and test diffs passed together; pixel chat results and stream checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant