Skip to content

Prevent model protocol envelopes from leaking into chat - #793

Draft
Y1fe1Zh0u wants to merge 2 commits into
dataelement:mainfrom
Y1fe1Zh0u:fix/natural-completion-output-protocol
Draft

Prevent model protocol envelopes from leaking into chat#793
Y1fe1Zh0u wants to merge 2 commits into
dataelement:mainfrom
Y1fe1Zh0u:fix/natural-completion-output-protocol

Conversation

@Y1fe1Zh0u

Copy link
Copy Markdown
Collaborator

What changed

  • Let tool-free, completed Assistant responses finish naturally without exposing a model-facing finish control tool.
  • Route leading <think>...</think> blocks into the existing structured reasoning channel instead of publishing them as message content.
  • Convert exact textual tool-call envelopes into real tool calls so execution and UI events use the normal tool path.
  • Reject unverified <result> / <tool_result> text with one bounded repair instead of presenting invented output as an executed result.
  • Decode the legacy Group finish JSON shape through the existing mention validation and handoff preflight path.
  • Preserve ordinary user-requested JSON; only unmistakable protocol structures are normalized.

Root cause

The Runtime treated any non-empty tool-free provider response as publishable Assistant content. Some providers place reasoning or pseudo tool protocol in that content, so <think> blocks, textual results, and the old Group finish JSON shape could reach the visible message body without structured execution or validation.

User impact

Private Agent chat now uses the existing Thinking and tool UI paths for structured activity. Group replies no longer expose legacy finish control fields, while Group mention routing still uses stable participant IDs and preflight validation.

Validation

  • Backend: 2117 passed
  • Frontend: 85 passed
  • Frontend production build: passed
  • Focused Ruff checks: passed
  • git diff --check: passed

Not tested

  • Live provider responses
  • Browser end-to-end verification against a deployed environment

Private Runs now complete from normal Assistant content and normalized provider stop reasons. Group Runs stage structured mentions through the dedicated at tool before the existing handoff preflight, keeping public text separate from routing intent.

Constraint: Preserve one-version compatibility for legacy finish checkpoints while removing finish from new model-visible tool schemas

Rejected: Parse arbitrary final-answer text as control JSON | would corrupt legitimate user-requested JSON responses

Confidence: high

Scope-risk: broad

Reversibility: clean

Directive: Keep Assistant content, provider termination, Group mention intent, and delivery side effects as separate contracts

Tested: 164 focused backend tests; git diff --check

Not-tested: Real provider and live Group child-Run E2E
Normalize embedded reasoning and exact textual tool structures before Runtime completion can publish them. Legacy Group finish JSON is decoded through the existing validation and handoff path, while unverified textual results receive one bounded repair instead of being shown as executed output. Ordinary user-requested JSON remains untouched.

Constraint: Thinking must use the existing reasoning channel and tool activity must use real tool events.

Rejected: Strip all JSON-looking output | would corrupt legitimate JSON answers and still bypass tool execution.

Confidence: high

Scope-risk: moderate

Directive: Do not broaden JSON detection without preserving ordinary user-requested JSON responses.

Tested: 2117 backend pytest tests; focused Ruff checks; git diff --check

Not-tested: Live provider and browser E2E
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