Skip to content

fix(reflect): emit canonical tool result messages#2765

Closed
Jordan-Jarvis wants to merge 2 commits into
vectorize-io:mainfrom
Jordan-Jarvis:fix/reflect-canonical-tool-results-20260717
Closed

fix(reflect): emit canonical tool result messages#2765
Jordan-Jarvis wants to merge 2 commits into
vectorize-io:mainfrom
Jordan-Jarvis:fix/reflect-canonical-tool-results-20260717

Conversation

@Jordan-Jarvis

Copy link
Copy Markdown
Contributor

Summary

  • remove the non-standard name field from Reflect role=tool messages
  • preserve the canonical OpenAI tool-result shape at the shared Reflect producer boundary
  • derive Gemini FunctionResponse.name from the immediately preceding assistant tool calls by tool_call_id
  • reject unknown, duplicate-within-turn, and missing tool results while allowing providers that reuse call IDs across turns

Root cause

Reflect currently adds name to tool-result messages for Gemini. Strict OpenAI-compatible gateways reject that extra field because tool-result messages permit content and tool_call_id; provider-specific requirements should be handled in the provider adapter instead of changing the canonical message shape.

Verification

  • targeted Ruff on all touched files
  • pytest -q tests/test_reflect_agent.py tests/test_gemini_safety_settings.py -k 'not RealLLM and not ContextOverflowIntegration' (69 passed)
  • repository pre-commit hooks and lint passed
  • git diff --check

No second Reflect path or compatibility fallback is introduced.

@Jordan-Jarvis

Copy link
Copy Markdown
Contributor Author

Superseded by #2766, which carries the same canonical producer/adapter fix with the stricter unknown-ID and duplicate-within-turn validation coverage. Keeping one upstream contribution avoids split implementations and duplicate review.

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