sync readme snippets with code + clean up formatting#43
Conversation
| @activity.defn | ||
| async def get_weather(city: str) -> Weather: | ||
| """Get the weather for a given city.""" | ||
| # introduce a bug |
There was a problem hiding this comment.
Do we want test error bugs in the code like this? The risk is that they become part of the training data.
| return result | ||
| ``` | ||
|
|
||
| ### The tool execution handler |
There was a problem hiding this comment.
Note, Claude justifies this change as follows:
The key improvement is that the README now shows the _execute_tool method as part of the complete AgentWorkflow class definition (lines 48-146 in the README), rather than splitting it into a separate code block. This accurately reflects the actual code structure in workflows/agent.py, where _execute_tool is a method of the AgentWorkflow class (lines 84-98).
What improved:
- Structural accuracy: The README now shows the full class definition in one code block, matching the actual file structure
- Better organization: The heading changed from "Create the tool execution handler" to "The tool execution handler" (line 148), which is more appropriate since it now appears after the code block that already showed the method
- Clearer relationship: It's now obvious that _execute_tool is a helper method within the same class, not a separate standalone function
The original structure was misleading because it made _execute_tool appear to be defined separately, when in reality it's just another method in the AgentWorkflow class.
There was a problem hiding this comment.
I don't feel strongly about how we go here. Having the method in a separate code block without the class definition was a little strange.
We can revert this if we want but we may need to update the sync script to keep it that way.
| return result | ||
| ``` | ||
|
|
||
| ### The function call handler |
There was a problem hiding this comment.
Claude explains this change as follows:
Before the change:
- The main agentic loop code block ended at the return result.output_text statement
- Then there was a heading "### Create the function call handler" with explanation
- Then a separate code block showing _handle_function_call as if it were defined separately
After the change:
- The _handle_function_call method is included in the same code block as the main AgentWorkflow class definition (lines 57-75 in the actual code)
- The heading changed to "### The function call handler" and moved after the complete code block
- The explanation now correctly describes a method that's already been shown, rather than introducing new code
This accurately reflects the actual structure in workflows/agent.py where _handle_function_call is a method of the AgentWorkflow class (lines 57-75), not a standalone function.
Why this matters:
The original structure was misleading because it suggested the function call handler was defined separately or could be understood in isolation. In reality, it's a helper method within the same class that uses self and is called by the main loop. The new structure makes this relationship clear and matches the actual code organization.
There was a problem hiding this comment.
I don't feel strongly about how we go here. Having the method in a separate code block without the class definition was a little strange. But I can also see how it flows better.
We can revert this if we want but we may need to update the sync script to keep it that way.
What was changed
Why?
Checklist
Closes
How was this tested: