Skip to content

Empty response from trustcall #62

@Chajf

Description

@Chajf

I'm encountering an issue where Trustcall returns empty outputs when structuring responses in the following environment:

While using trustcall for structing output in configuration with

  • Langchain Ollama - 0.3.6
  • Langgraph - 0.3.5
  • Qwen3:8b and GPT-oss:20b
  • Trustcall - 0.0.39

When invoking, I receive responses with no content in either the messages or responses fields, even though token usage and execution times indicate the model generated something.

Example empty output

{
    "messages": [
        {
            "content": "",
            "additional_kwargs": {},
            "response_metadata": {
                "model": "qwen3:latest",
                "created_at": "2025-08-14T12:19:40.795352902Z",
                "done": true,
                "done_reason": "stop",
                "total_duration": 102373450948,
                "load_duration": 85624850,
                "prompt_eval_count": 7667,
                "prompt_eval_duration": 3286289025,
                "eval_count": 5008,
                "eval_duration": 98940289640,
                "model_name": "qwen3:latest"
            },
            "type": "ai",
            "name": null,
            "id": "run--617ad51e-0611-4f60-a167-a8b545926c4d-0",
            "example": false,
            "tool_calls": [],
            "invalid_tool_calls": [],
            "usage_metadata": {
                "input_tokens": 7667,
                "output_tokens": 5008,
                "total_tokens": 12675
            }
        }
    ],
    "responses": [],
    "response_metadata": [],
    "attempts": 1
}

Increasing the model context (num_ctx) sometimes resolves the issue for specific inputs, but it's inconsistent. Importantly, the problem seems related to tool calls: for the same or smaller context and identical input, the behavior changes—sometimes I get valid tool call responses.

For same input as provided before we can get valid answer:

{
    "messages": [
        {
            "content": "",
            "additional_kwargs": {},
            "response_metadata": {
                "model": "qwen3:latest",
                "created_at": "2025-08-14T12:58:48.480010548Z",
                "done": true,
                "done_reason": "stop",
                "total_duration": 115513915397,
                "load_duration": 107242045,
                "prompt_eval_count": 7667,
                "prompt_eval_duration": 3792590206,
                "eval_count": 5404,
                "eval_duration": 111556287803,
                "model_name": "qwen3:latest"
            },
            "type": "ai",
            "name": null,
            "id": "run--4f9b619c-b015-408d-a9b1-d19a3ec5f1cf-0",
            "example": false,
            "tool_calls": [
                {
                    "id": "c3d88e80-9632-4c2d-964d-49cf13f7e3d3",
                    "name": "Epic",
                    "args": { [...] }
        }
    ],
    "response_metadata": [
        {
            "id": "c3d88e80-9632-4c2d-964d-49cf13f7e3d3"
        }
    ],
    "attempts": 2
}

Configuration Snippet:

extractor = create_extractor(llm, tools=[Epic], tool_choice="Epic")
chain = prompt | extractor
ans = chain.invoke(
    input={
        "chat_history": [],
        "user_input": msg,
    }
)

After printing ans on empty response

{'messages': [AIMessage(content='', additional_kwargs={}, response_metadata={'model': 'qwen3:latest', 'created_at': '2025-08-14T10:41:53.470475984Z', 'done': True, 'done_reason': 'stop', 'total_duration': 97660323124, 'load_duration': 97297347, 'prompt_eval_count': 4519, 'prompt_eval_duration': 1898189101, 'eval_count': 4036, 'eval_duration': 95598085728, 'model_name': 'qwen3:latest'}, id='run--f57dadae-a667-4bb5-9fa1-fff9ed43fb05-0', usage_metadata={'input_tokens': 4519, 'output_tokens': 4036, 'total_tokens': 8555})], 'responses': [], 'response_metadata': [], 'attempts': 1}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions