Getting error in databricks agent response

ajaygshah
New Contributor II

I have selected a non-instruct model: databricks-qwen35-122b-a10b. Although the model doesn't matter. So when I type anything in the chat UI after deployment, the response is always along these lines:

{
  "detail": "1 validation error for ResponseOutputText\ntext\n  Input should be a valid string [type=string_type, input_value=[{'type': 'reasoning', 's...rprised you the most?\"}], input_type=list]\n    For further information visit https://errors.pydantic.dev/2.13/v/string_type"
}

 I tried changing the stream input/output cleaning. But this error is persistent. Is there any known behavior with the MlFlow library that is actually taking the output text and working on it?  Or is this a known behavior which is being actively worked on?

DoTA
New Contributor III

Hi @ajaygshah — this is documented Databricks behavior, not a bug in your stream cleaning.

databricks-qwen35-122b-a10b is a reasoning-only model - per the supported models docs (https://docs.databricks.com/aws/en/machine-learning/foundation-model-apis/supported-models), it "always reasons before responding, and reasoning cannot be disabled." So every response comes back as a list of typed content blocks, not a flat string — a reasoning block followed by a text/output_text block, per the querying reasoning models guide (https://docs.databricks.com/aws/en/machine-learning/model-serving/query-reason-models😞

 

content=[

    {"type": "reasoning", "summary": [{"type": "summary_text", "text": "..."}]},

    {"type": "text", "text": "..."}

]

 

Whatever's feeding your chat UI is forwarding that whole content list into a field that expects a plain string (ResponseOutputText.text requires str) - which is exactly the pydantic error you're getting: input_value=[{'type': 'reasoning', ...}].

 

The fix is to pull out only the final block before returning it, per Databricks' own extraction pattern:

 

answer = next(b["text"] for b in msg.content if b["type"] == "text")

 

(or msg.content[-1]["text"] if you can rely on ordering). If you're on a custom pyfunc/ResponsesAgent wrapper, do this filtering in predict/predict_stream before constructing the output. If you're hitting a stock Foundation Model API endpoint directly with no code of your own in between, then the client you're using (Playground, a UI, etc.) needs to handle multi-block content - that'd be worth flagging to Databricks support since you have no code path to intercept it.