Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,19 @@ async def on_agent_response(
"""Handle the agent's guess and request human guidance.

Steps:
1) Parse the agent's JSON into GuessOutput for robustness.
1) Use .value to access the parsed structured output directly.
2) Request info with a HumanFeedbackRequest as the payload.
"""
# Parse structured model output
text = result.agent_response.text
last_guess = GuessOutput.model_validate_json(text).guess
# Access the parsed structured model output via .value.
# Since the agent is configured with response_format=GuessOutput,
# .value returns the parsed GuessOutput instance directly.
agent_value = result.agent_response.value
if agent_value is None:
raise RuntimeError(
"AgentResponse.value is None. Ensure that the agent is invoked with "
"options={'response_format': GuessOutput} so structured output is available."
)
last_guess = agent_value.guess

# Craft a precise human prompt that defines higher and lower relative to the agent's guess.
prompt = (
Expand Down