huggingface / huggingface/smolagents
How to capture CodeAgent's full thinking including the code, not just the final response into a variable
- Dominant language
- Python
- Stars
- 29.4k
- Forks
- 3k
- Avg merge
- 17m
- Merged PRs (30d)
- 2
Description
When we run a CodeAgent in a notebook, it print the question/task, the LLM model used, code (Executing this code, Execution logs) and the Final answer.
The return value from agent.run contrains only the final response.
I'm working on some demos for which I wanted to run a number of tasks, capture all the output (not just the final answer) and write them to an md or html file, so that I can show everything including the code generated by the agent without running the agents live in the demo.
I tried logging, stdout, from contextlib import redirect_stdout, etc but couldn't capture the full output to a variable.
Thanks,
Contributor guide
Research direction
Start by tracing CodeAgent execution from agent.run in the notebook context, including where the question, model, generated code, execution logs, and final answer are emitted. Check whether stdout or the existing logging path contains these messages. Done means a caller can capture the complete rendered output in a variable while agent.run continues to provide its final response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100