Repository: UKGovernmentBEIS/inspect_ai
Issue: Extract reasoning block from OpenRouter API
Root cause: Interface Contract Mismatch

When using OpenRouter API recently, the assistant reasoning returns as 

```
[{"format": "unknown", "index": 0, "type": "reasoning.text", "text": }]
```

For example

![](https://private-user-images.githubusercontent.com/46087525/530852189-3ce66475-9abb-48e4-8832-21f8d1e19d13.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NjcwNjg5NTcsIm5iZiI6MTc2NzA2ODY1NywicGF0aCI6Ii80NjA4NzUyNS81MzA4NTIxODktM2NlNjY0NzUtOWFiYi00OGU0LTg4MzItMjFmOGQxZTE5ZDEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTEyMzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUxMjMwVDA0MjQxN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQzZDllNDgxZjk2YjFmNzVmMjg2Njg1ZTc4YWI1NzQ0OWU2MmVhYWY1NWY3MWU5ZjU3ZjJjMWRjZjczNDg4MjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.e6DEFgOhThWeF43hnS_NURSwWGfkm1NSxqoORwG6E8o)

I'm using newest Inspect version (0.3.158), which should have added the fix from #2955 , but the error persists.

Additionally, I noticed that Inspect viewer shows
- Version 0.3.156-5-gf44a52cd2
- Schema 9


Thanks for reporting this. Could you provide a bit more of an end to end repro so we can investigate?

Reproducible code here. You will need an OpenRouter API key, and any reasoning model. 

```python
#!/usr/bin/env python3
"""Simple script to send a question using Inspect AI.

Usage:
    uv run python scripts/simple_question.py
    uv run python scripts/simple_question.py "What is 2+2?"
"""

import sys

from inspect_ai import Task, eval as inspect_eval
from inspect_ai.dataset import Sample
from inspect_ai.model import GenerateConfig
from inspect_ai.solver import generate

MODEL = "openrouter/qwen/qwen3-14b"

QWEN3_GENERATE_CONFIG = GenerateConfig(
    temperature=0.6,
    max_tokens=12000,
    repetition_penalty=1.05,
    extra_body={
        "reasoning": {
            "max_tokens": 10000,
        },
        "min_p": 0.05,
    },
)

DEFAULT_QUESTION = "What is the capital of France? Think step by step."


def create_task(question: str) -> Task:
    """Create a simple task with a single question."""
    return Task(
        dataset=[Sample(input=question, id="q1")],
        solver=generate(),
        config=QWEN3_GENERATE_CONFIG,
    )


def main() -> None:
    """Send a question to the model and print the response."""
    question = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_QUESTION

    task = create_task(question)
    results = inspect_eval(task, model=MODEL)

    # Extract and print the response
    if results and results[0].samples:
        sample = results[0].samples[0]
        print(f"Question: {question}")

        if sample.output and sample.output.completion:

            print("Response:")
            print(sample.output.completion)
        else:
            print("No completion in response")
    else:
        print("No results returned")


if __name__ == "__main__":
    main()
```

When running `uv run inspect view`, the assistant reasoning looks like this:
```
[{"format": null, "index": 0, "type": "reasoning.text", "text": "\nOkay, the user asked &quot;What is 2+2?&quot; That seems straightforward, but I need to make sure I handle it correctly. Let me think. .... "}]
```
It relates to PR #2955 .

Btw. Inspect Viewer shows it's version 0.3.156-5-gf44a52cd2, although I have 0.3.158 installed.

I see! So the issue IIUC is the the reasoning display in the viewer is not very readable/comprehensible -- is that correct or is there an additional underlying protocol level problem?

Okay, this PR will make the reasoning rendering correct: https://github.com/UKGovernmentBEIS/inspect_ai/pull/2996

Note that this will work for new evals only (older eval logs created before this change will still exhibit the same rendering issues).