minor slackbot improvements#1177
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Slackbot’s progress reporting by tracking and displaying how many times each tool is used, and ensures counts are initialized and cleared per agent run.
- Introduce
ContextVars to track tool usage and current tool inwrap.py - Revamp progress message formatting to include a summary of tool counts
- Initialize and reset the tool-usage context in
run_agent(inapi.py) - Clarify version-defaulting rules in
research_agent.py
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| examples/slackbot/src/slackbot/wrap.py | Added ContextVars for usage counts/current tool and updated progress formatting |
| examples/slackbot/src/slackbot/research_agent.py | Made Prefect-3.x default rule more prominent (but duplicated) |
| examples/slackbot/src/slackbot/api.py | Initialize and reset _tool_usage_counts around run_agent |
|
|
||
| return result | ||
| finally: | ||
| if _progress: |
There was a problem hiding this comment.
_current_tool_token may not be defined if an exception is raised before it's set, causing an UnboundLocalError. Consider defining a default token or guarding the reset to ensure the variable exists.
| if _progress: | |
| if _progress and _current_tool_token is not None: |
|
|
||
| return result | ||
| finally: | ||
| if _progress: |
There was a problem hiding this comment.
Resetting _current_tool only when _progress is truthy can leave the context var set in other cases, leaking state. The reset should be unconditional or independently guarded.
| if _progress: | |
| if _current_tool_token is not None: # Reset unconditionally if token is set |
| 6. Review gotchas and release notes for recent changes | ||
|
|
||
| CRITICAL VERSION-SPECIFIC RULES: | ||
| - **DEFAULT TO PREFECT 3.x**: Do NOT use search_prefect_2x_docs unless user explicitly mentions "2.x", "Prefect 2", or asks about version differences |
There was a problem hiding this comment.
[nitpick] This rule repeats the guidance already stated in item 5 above. Consider removing one of the duplicates to keep the documentation concise and avoid confusion.
| - **DEFAULT TO PREFECT 3.x**: Do NOT use search_prefect_2x_docs unless user explicitly mentions "2.x", "Prefect 2", or asks about version differences |
No description provided.