r/ZooCode • • 1d ago

Zoo Code (VS Code) loops on "Model Response Incomplete" with my local OpenAI-compatible gateway routing to Gemini/NVIDIA/Ollama models

I'm building a local gateway in FastAPI (uvicorn, port 8000) that exposes /v1/chat/completions in OpenAI format and routes requests to several providers through fallback chains: Gemini (gemini-3-flash-preview), NVIDIA NIM (550B-class models and others), and a local Ollama model (qwen2.5-coder:14b). I use Zoo Code (a VS Code extension) with the profile pointed at http://127.0.0.1:8000/v1, with custom modes like "Architect" and "Orchestrator."

Symptom: When I send an agentic task in Zoo (which sends tools and usually stream: true), the extension repeatedly shows Model Response Incomplete ("the model failed to use any tools in its response") and then Zoo is having trouble.... The tool is never executed.

What I've tested (with curl, directly against the gateway):

  • backend mode without tools: responds normally via Gemini, with content filled in.
  • architect mode with tools and stream: true: returns tool_calls with list_files from Gemini. This works after a streaming fix that makes the upstream call without streaming when tools are present and returns the result as SSE.
  • The Ollama model qwen2.5-coder:14b called through the native API (/api/chat) with tools: it returns the tool call JSON as plain text inside content, without structured tool_calls. So this model is not using tools in the expected format.
  • maestro mode with tools: previously, the gateway ignored tools and returned text from an internal orchestrator (supervisor-worker) with no tool_calls. After I routed these requests through the normal fallback chain, the test passed, but the first attempt took about 55 seconds (the timeout of the 550B model) before falling back to Gemini.

Current hypothesis: the Zoo profile sends orchestrator/maestro, which used to go to an internal flow without tool_calls. I have not yet confirmed this in the Zoo logs.

What I don't know yet:

  • Whether Zoo really sends stream: true, and the exact model name in the profile.
  • Why the chain doesn't move to the next model when a response is empty.
  • Whether Zoo's default timeout is shorter than the fallback time.

Information I can share: excerpts from gateway/app.py (streaming and tool_calls handling), routing_config.json, the output of tail -n 60 logs/gateway.log right after a failure, and the Zoo mode configuration JSON (without API keys).

Question: Has anyone used Zoo Code (or Roo Code, which it is based on) with an OpenAI-compatible gateway and models without native tool-calling support? Is there a response format the extension expects that I should guarantee in streaming? Thanks.

2 Upvotes

1 comment sorted by

2

u/p3rdy 1d ago

Your Ollama test already shows the main problem: if the tool call comes back as JSON inside content, Zoo sees a text answer with no tool_calls, which is exactly "the model failed to use any tools". Whichever provider ends up answering, the gateway has to hand Zoo structured tool_calls, and there are three places where that breaks.

1. Text tool calls from the local model. Either parse them in the gateway (look for a {"name": ..., "arguments": ...} object or a <tool_call>...</tool_call> block in content and move it into tool_calls), or never route requests that carry tools to a model that does this. Routing tool requests elsewhere is the simpler fix while you debug.

2. The fake stream. When you call upstream without streaming and re-emit it as SSE, the chunks have to look like a real tool-call stream or the client's accumulator ends up empty:

data: {"choices":[{"index":0,"delta":{"role":"assistant","tool_calls" [{"index":0,"id":"call_1","type":"function","function": "name":"list_files","arguments":""}}]}}]}
data: {"choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"path\":\".\"}"}}]}}]}
data: {"choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}]}
data: [DONE]

The usual misses are the index on each tool call, arguments as a string rather than an object, and finish_reason: "tool_calls" on the last chunk.

3. Empty answers and slow fallbacks. Treat "tools were sent, and the reply has neither tool_calls nor content" as a failure and move to the next model in the chain, the same as an error. Give each provider a short time-to-first-response limit instead of one 55-second timeout, so the fallback happens before the client gives up.

For the parts you don't know yet: log the incoming request body (model, stream, how many tools) before routing. One failed run will show what the profile really sends.

For the local leg specifically: I maintain Flama, an open-source Python framework that can serve the model itself instead of Ollama, on MLX or vLLM. It detects the model's tool-call format when it warms up and returns proper tool_calls on its OpenAI-compatible endpoint, so your gateway would get structured calls from that leg instead of having to parse them.