Skip to content

Guidance error when tool_choice=required #335

@natke

Description

@natke

Foundry Local version 0.8.113 is giving the following error when tool_choice=required, for some payloads.

This is the error:

"Error creating grammar: failed to parse \"%json\": control character (\\u0000-\\u001F) found while parsing a string at line 12 column 0"

Example payload

{
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful email and calendar assistant.\n\nCurrent date: 2025-11-29\n\nYou have access to the following tools:\n- search_emails: Search for emails containing specific keywords\n- get_latest_emails: Get the most recent emails\n- search_calendar: Search calendar events by query or date\n- get_upcoming_events: Get upcoming calendar events\n\nWhen the user asks a question:\n1. Use the appropriate tools to gather information\n2. Synthesize a clear, specific answer based on the tool results\n3. Include relevant details like dates, times, subjects, and people\n\nBe concise but informative."
    },
    {
      "role": "user",
      "content": "Search for any emails from Bob"
    }
  ],
  "model": "qwen2.5-1.5b-instruct-generic-gpu:4",
  "max_tokens": 1024,
  "stream": false,
  "tool_choice": "required",
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "search_emails",
        "description": "Search emails for a specific query string.\n\nArgs:\n    query: Search query to find in emails\n    max_results: Maximum number of results to return (default: 5)\n\nReturns:\n    Formatted string with matching emails",
        "parameters": {
          "type": "object",
          "properties": {
            "query": {
              "type": "string",
              "description": "Search query to find in emails or events"
            },
            "max_results": {
              "type": "integer",
              "description": "Maximum number of results to return"
            }
          },
          "required": [
            "query",
            "max_results"
          ]
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "get_latest_emails",
        "description": "Get the most recent emails.\n\nArgs:\n    count: Number of recent emails to retrieve (default: 5)\n\nReturns:\n    Formatted string with recent emails",
        "parameters": {
          "type": "object",
          "properties": {
            "count": {
              "type": "integer",
              "description": "Number of recent emails to retrieve"
            }
          },
          "required": [
            "count"
          ]
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "search_calendar",
        "description": "Search calendar events by query or date.\n\nArgs:\n    query: Required search query for event subject\n    date: Required date in YYYY-MM-DD format to filter events\n\nReturns:\n    Formatted string with matching calendar events",
        "parameters": {
          "type": "object",
          "properties": {
            "query": {
              "type": "string",
              "description": "Search query for event subject"
            },
            "date": {
              "type": "string",
              "description": "Date in YYYY-MM-DD format to filter events"
            }
          },
          "required": [
            "query",
            "date"
          ]
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "get_upcoming_events",
        "description": "Get upcoming calendar events for the next N days.\n\nArgs:\n    days: Number of days to look ahead (default: 7)\n\nReturns:\n    Formatted string with upcoming events",
        "parameters": {
          "type": "object",
          "properties": {
            "days": {
              "type": "integer",
              "description": "Number of days to look ahead"
            }
          },
          "required": [
            "days"
          ]
        }
      }
    }
  ]
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions