Skip to content

fix(reflect): reject serialized parameter tails in done answers - #3074

Closed
Alan5168 wants to merge 2 commits into
vectorize-io:mainfrom
Alan5168:fix/reflect-done-answer-tail
Closed

fix(reflect): reject serialized parameter tails in done answers#3074
Alan5168 wants to merge 2 commits into
vectorize-io:mainfrom
Alan5168:fix/reflect-done-answer-tail

Conversation

@Alan5168

Copy link
Copy Markdown
Contributor

Summary

Reject a parsed done tool call when its answer contains a serialized sibling parameter tail such as </answer><parameter name="memory_ids">....

Some provider responses can return a valid tool call while blending XML tool serialization into the JSON answer value. Because a tool call exists, the no-tool-call guard added in #3013 does not run, and the corrupted tail gets persisted verbatim into mental_models.content.

This validates the exact answer/sibling-parameter boundary against the declared done() fields and raises ReflectToolCallError (matching the existing fail-loud contract). It does not truncate or silently clean the answer, and it does not touch #3013's no-tool-call guard.

Tests

  • Added test_done_tool_rejects_serialized_parameter_tail, a regression test that is red on current main and green with the fix (verified locally by reverting just the production fix and re-running).
  • 40 passed across the related pure unit tests in test_reflect_agent.py (excluding RealLLM/Integration/DirectiveLeakageOnEmptyBank, which need external providers/deps not available here).
  • ruff check and ruff format --check pass for all changed Python files.

Closes #3048

@nicoloboschi

Copy link
Copy Markdown
Collaborator

seems like a model issue, let's not open the pandora's box

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.

reflect: leaked done-tool tail still persists when the model DOES emit a valid tool call (#3013 guard does not fire)

2 participants