Python: Preserve reasoning blocks with OpenRouter (#2950)

* Preserve reasoning blocks with OpenRouter

* Put encrypted reasoning in TextReasoningContent

* Remove unneccessary change

* Fix docs

* Support streaming

* Fix handling None in TextReasoningContent.text
This commit is contained in:
SuperKenVery
2025-12-20 01:03:19 +08:00
committed by GitHub
Unverified
parent 6930c0f0b6
commit 85d70f01f6
4 changed files with 41 additions and 5 deletions
@@ -30,7 +30,7 @@ async def reasoning_example() -> None:
print(f"User: {query}")
# Enable Reasoning on per request level
result = await agent.run(query)
reasoning = "".join(c.text for c in result.messages[-1].contents if isinstance(c, TextReasoningContent))
reasoning = "".join((c.text or "") for c in result.messages[-1].contents if isinstance(c, TextReasoningContent))
print(f"Reasoning: {reasoning}")
print(f"Answer: {result}\n")