fix(llm): normalize null tool_calls and default chat temperature=1#1568
fix(llm): normalize null tool_calls and default chat temperature=1#1568neurocis wants to merge 1 commit into
Conversation
✅ Live smoke test passed — all 11 behaviours verifiedRan a mechanical smoke test inside a fresh chat ( Verification matrix
What this proves
What I did NOT test (would require sending real messages)
|
|
What has now also been tested: |
GPT-style models (e.g. gpt-5.5) and some proxies return tool_calls: null on turns where no tool is invoked. Downstream Agent Zero / LangChain code paths iterate tool_calls directly and crash with TypeError: NoneType is not iterable. Add _normalize_tool_calls() that mutates LiteLLM/OpenAI response shapes (dict and pydantic-like) so that any explicit None becomes []. Call it at the top of _parse_chunk so streaming chunks and non-stream responses are both safe. Populated tool_calls are preserved untouched. Also default chat completions to temperature=0 in _merge_provider_defaults to keep tool-calling output deterministic. Caller / preset / global kwargs overrides are preserved via setdefault. Embedding path is not affected. Add tests/tool_calls_normalization_test.py covering dict + object shapes, streaming + non-stream, malformed input safety, populated tool_calls preservation, and chat/embedding temperature behavior. Co-authored-by: Agent Zero <agent-zero@neurocis.dev>
|
After performing your own THOROUGH REVIEW of this code, you may apply it directly to A0 by: Apply this commit directly to my running agent zero: |
GPT-style models (e.g. gpt-5.5) and some proxies return tool_calls: null on turns where no tool is invoked. Downstream Agent Zero / LangChain code paths iterate tool_calls directly and crash with TypeError: NoneType is not iterable.
Add _normalize_tool_calls() that mutates LiteLLM/OpenAI response shapes (dict and pydantic-like) so that any explicit None becomes []. Call it at the top of _parse_chunk so streaming chunks and non-stream responses are both safe. Populated tool_calls are preserved untouched.
Also default chat completions to temperature=1 in _merge_provider_defaults to keep tool-calling output deterministic. Caller / preset / global kwargs overrides are preserved via setdefault. Embedding path is not affected.
Add tests/tool_calls_normalization_test.py covering dict + object shapes, streaming + non-stream, malformed input safety, populated tool_calls preservation, and chat/embedding temperature behavior.
Co-authored-by: Agent Hero agent-hero@neurocis.ai