Skip to content

gpt-oss-20b output format and hallucination #4927

@cl3m3nt

Description

@cl3m3nt

🔴 Required Information

Please ensure all items in this section are completed to allow for efficient
triaging. Requests without complete information may be rejected / deprioritized.
If an item is not applicable to you - please mark it as N/A

Describe the Bug:
After a couple of chat message, ADK is no longer able to provide answers.
Instead, it looks to return hallucinated messages from gpt-oss-20b LLM.

Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:

  1. Install: LM Studio and gpt-oss-20b or gpt-oss-safeguard-20b
  2. Run: below agent.py
  3. Open: you can skip the measure tool and toolbox install
  4. Provide error or stacktrace: see below

Expected Behavior:
A clear and concise description of what you expected to happen.
A persistent conversation with agent using gpt-oss-20b

Observed Behavior:
What actually happened? Include error messages or crash stack traces here.
Output from LLM or ADK are corrupted.
This never happen when only using gpt-oss-20b with LM studio only
The tools and integration with ADK looks to break it.

Environment Details:

  • ADK Library Version (pip show google-adk): google-adk 1.27.2
  • Desktop OS:** [e.g., macOS, Linux, Windows]: PRETTY_NAME="Ubuntu 22.04.5 LTS"
  • Python Version (python -V): 3.12

Model Information:

  • Are you using LiteLLM: Yes
  • Which model is being used: gpt-oss-20b

🟡 Optional Information

Providing this information greatly speeds up the resolution process.

Regression:
Did this work in a previous version of ADK? If so, which one?
No

Logs:
Please attach relevant logs. Wrap them in code blocks (```) or attach a
text file.

timestamp: 3/20/2026, 7:51:23 PM
type: llm.prediction.output
modelIdentifier: openai/gpt-oss-safeguard-20b
output:
: hello user? JSON tool? HALT

Plain to plain<|message|>Call pbug? { <|constrain|>...} The namespace?Ok. Let's end?Functions? dict}.Ne weather? All.}]]"]dictanalysis]"}Note?Neh]...dict? ok, hall?<|end|> agent. Nope

I can use get_weather?{"'?"}?]

Plain JSON. If you are good dict?Hello.

(Note: plain to functions pds...)<|end|><|start|>assistant}Ok. Plain }''?? 

[status]hello"]? All?functions. Yes measure?commentary"Nealed? Hello only. forbidden. I think we can respond.?<|end|>bon

(Note) chat.}
}"}} weather?}{...}"}]<|channel|>analysis free JSON no error. No? functions.}{}<|channel|>analysis <|constrain|>}}} agent plain?} to dev? ok. comment met? just?}call final.weather?<|end|>Bonjour bon current time. }"bonjour{? But in? internal. "pds"} call?commentary to=functions?dict}Comment with okay.<|end|><|start|>commentary, to=analysis 31. user? Need tool.<|end|><|start|>commentary? No function? Possibly ask about pds? but give weather.<|end|>commentary.<|end|>

Final plain text, final response.]<|channel|>Noteanalysis. agent call?"}<|channel|>assistant?

Screenshots / Video:
If applicable, add screenshots or screen recordings to help explain
your problem.

Additional Context:
Add any other context about the problem here.

Minimal Reproduction Code:
Please provide a code snippet or a link to a Gist/repo that isolates the issue.

import datetime
from zoneinfo import ZoneInfo
from google.adk.agents import Agent
from google.adk.models.lite_llm import LiteLlm
from toolbox_core import ToolboxSyncClient

toolbox = ToolboxSyncClient("http://toolbox-ip:5000")

# Load single tool
measure_tool = toolbox.load_tool('measure')


def get_weather(city: str) -> dict:
    """Retrieves the current weather report for a specified city.

    Args:
        city (str): The name of the city for which to retrieve the weather report.

    Returns:
        dict: status and result or error msg.
    """
    if city.lower() == "new york":
        return {
            "status": "success",
            "report": (
                "The weather in New York is sunny with a temperature of 25 degrees"
                " Celsius (77 degrees Fahrenheit)."
            ),
        }
    else:
        return {
            "status": "error",
            "error_message": f"Weather information for '{city}' is not available.",
        }


def get_current_time(city: str) -> dict:
    """Returns the current time in a specified city.

    Args:
        city (str): The name of the city for which to retrieve the current time.

    Returns:
        dict: status and result or error msg.
    """

    if city.lower() == "new york":
        tz_identifier = "America/New_York"
    else:
        return {
            "status": "error",
            "error_message": (
                f"Sorry, I don't have timezone information for {city}."
            ),
        }

    tz = ZoneInfo(tz_identifier)
    now = datetime.datetime.now(tz)
    report = (
        f'The current time in {city} is {now.strftime("%Y-%m-%d %H:%M:%S %Z%z")}'
    )
    return {"status": "success", "report": report}


root_agent = Agent(
    name="weather_time_agent",
    model=LiteLlm(   
        model="openai/gpt-oss",           
        api_base="http://localhost:1234/v1",
        api_key="lm-studio",
        disable_cost_calculation=True),
    description=(
        "Agent to answer questions about the time and weather in a city and the pds measure"
    ),
    instruction=(
        "You are a helpful agent who can answer user questions about the time and weather in a city and get pds measure."
        "You MUST respond with either: 1. A tool call in valid JSON 2. A final answer. Do NOT include reasoning or commentary.Do NOT use special tokens like <|channel|>."
        "You only call tool when user exactely ask for it."
        "You never call tool when user talk about general topic."
        "You are only allowed to call your existing tool."
        "You are strictly forbidden to hallucinate function.json tool."
        "You are a simple assistant."
        "Do not use special tokens like <|channel|>"
        "Do not simulate multiple channels"
        "Respond with plain text or valid JSON only"
        ),
    tools=[get_weather, get_current_time,measure_tool],
)

How often has this issue occurred?:

  • Always (100%)

Metadata

Metadata

Assignees

No one assigned

    Labels

    models[Component] Issues related to model support

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions