You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support role: "tool" / tool_call_id feedback for tool results #1389
What: Feed tool results back to OpenAI-compatible providers as role: "tool" messages with a matching tool_call_id, instead of as user text.
Why: Spec-strict providers may still mishandle the result turn even though the assistant tool-call turn is now correct. The PR author flagged this as intentionally out of scope The role: "tool" / tool_call_id feedback half (the reporter currently feeds tool results back as user text) is left as a follow-up.
Scope: ToolMessage/Message serialization in mellea/helpers/openai_compatible_helpers.py, plus wherever tool results are appended to context.
Heads-up from the execute_tool span work (#1430): that PR adds ModelToolCall.tool_call_id, populated with the real provider-supplied call id end-to-end — non-streaming and streaming, across the OpenAI-compatible, LiteLLM, Watsonx, and Ollama backends. It's None only for raw-string tool parsing and providers that don't send an id.
With that field now available, the threading/serialization work here has two concrete spots:
Result turn (this issue's core):ToolMessage carries its ModelToolCall (_tool), so the result turn can read the genuine id from _tool.tool_call_id instead of inventing one.
Assistant turn:build_tool_calls (mellea/helpers/openai_compatible_helpers.py:407) currently fabricates a fresh random id (f"call_{uuid.uuid4().hex[:24]}") on every replayed tool-call turn, discarding the provider's original. It should use model_tool_call.tool_call_id when present, falling back to a generated id only when it's None.
These two should land together: threading the real id into the result turn while the assistant turn still uses a fabricated one would leave the call and its result with mismatched ids. #1430 intentionally left build_tool_calls:407 as-is — capturing the id is in scope for the span work, spending it (replay serialization) belongs here.
Activity
ajbozarth commentedon Jul 22, 2026
Heads-up from the
execute_toolspan work (#1430): that PR addsModelToolCall.tool_call_id, populated with the real provider-supplied call id end-to-end — non-streaming and streaming, across the OpenAI-compatible, LiteLLM, Watsonx, and Ollama backends. It'sNoneonly for raw-string tool parsing and providers that don't send an id.With that field now available, the threading/serialization work here has two concrete spots:
ToolMessagecarries itsModelToolCall(_tool), so the result turn can read the genuine id from_tool.tool_call_idinstead of inventing one.build_tool_calls(mellea/helpers/openai_compatible_helpers.py:407) currently fabricates a fresh random id (f"call_{uuid.uuid4().hex[:24]}") on every replayed tool-call turn, discarding the provider's original. It should usemodel_tool_call.tool_call_idwhen present, falling back to a generated id only when it'sNone.These two should land together: threading the real id into the result turn while the assistant turn still uses a fabricated one would leave the call and its result with mismatched ids. #1430 intentionally left
build_tool_calls:407as-is — capturing the id is in scope for the span work, spending it (replay serialization) belongs here.