Game Time: Run the Full Agent
Your basketball coaching agent is almost ready to hit the court. You've written a callback function to show the step number and token usage.
Now it's time to assemble everything: you'll configure a CodeAgent
that uses that callback.
You already have access to:
- A
basketball_tool
that enables the agent to search scouting reports - A
model
variable with your language model - A callback function:
action_callback
Your goal is to finish wiring up the agent.
This exercise is part of the course
AI Agents with Hugging Face smolagents
Exercise instructions
- Import the
ActionStep
class so it can be used to register the action callback. - Register the
action_callback
function for theActionStep
class so the agent shows its actions while executing.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import ActionStep to register a callback for it
from smolagents import ____
coach_agent = CodeAgent(
tools=[basketball_tool],
model=model,
verbosity_level=0,
# Register a callback that runs when an ActionStep is triggered
step_callbacks={ActionStep: ____}
)
# Run a question through the agent
result = coach_agent.run("What defensive strategy should we use to stop their point guard who averages 25 points per game?")
print(result)