Skip to content

fix: doom loop not detected for repeated identical tool validation errors #506

@bug-ops

Description

@bug-ops

Bug

When using orchestrator with Claude as default provider, the write tool is called via native tool_use path but Claude omits the content parameter, causing repeated execution failed: missing required parameter: content errors.

Investigation

  1. Orchestrator correctly routes chat_with_tools to Claude (default = "claude")
  2. Claude supports_tool_use() -> true, so native tool_use path is used
  3. Tool schema is generated via schemars::schema_for!(WriteParams) and serialized with serde_json::to_value(&def.schema) which produces a RootSchema wrapper (includes $schema, title, definitions metadata)
  4. Claude API input_schema expects a clean JSON Schema object with type, properties, required at the top level
  5. The extra schemars wrapper may confuse Claude into not recognizing required fields

Likely root cause

tool_def_to_definition() in streaming.rs:757 passes the full RootSchema as parameters, but Claude API expects just the schema body. The schemars RootSchema has a nested structure:

{
  "$schema": "...",
  "title": "WriteParams",
  "type": "object",
  "properties": { "path": {...}, "content": {...} },
  "required": ["path", "content"]
}

If the extra fields cause Claude to misinterpret the schema, it may not enforce required parameters properly.

Proposed fix

  1. Verify the actual JSON being sent to Claude API (add trace logging for tool definitions)
  2. If schemars wrapper is the issue: extract .schema from RootSchema or strip $schema/title fields before passing to Claude
  3. Add a test that validates the tool definition JSON structure matches what Claude API expects

Secondary issue

TUI header shows Model: glm-4.7-flash:latest instead of the actual Claude model because main.rs:267 sets model_name from config.llm.model (Ollama model) rather than from the orchestrator's active provider. This is cosmetic but misleading.

Steps to reproduce

  1. Configure orchestrator with Claude as default and Ollama model in [llm]
  2. Start TUI, ask agent to write a file
  3. Observe repeated missing required parameter: content errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions