Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make AssistantAgent and Handoff use BaseTool #5193

Merged
merged 5 commits into from
Jan 25, 2025
Merged

Conversation

victordibia
Copy link
Collaborator

Why are these changes needed?

Make AssistantAgent and Handoff use BaseTool.
This ensures that they can be made declarative/serialized

Related issue number

Checks

Copy link

codecov bot commented Jan 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.08%. Comparing base (b6597fd) to head (42e6bee).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5193      +/-   ##
==========================================
- Coverage   70.08%   70.08%   -0.01%     
==========================================
  Files         179      179              
  Lines       11620    11619       -1     
==========================================
- Hits         8144     8143       -1     
  Misses       3476     3476              
Flag Coverage Δ
unittests 70.08% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@victordibia
Copy link
Collaborator Author

victordibia commented Jan 25, 2025

@jackgerrits @ekzhu ,

It seems we are hitting the covariant/contravariant issue with BaseToool similar to component config.

ArgsT = TypeVar("ArgsT", bound=BaseModel, contravariant=True)
ReturnT = TypeVar("ReturnT", bound=BaseModel, covariant=True)
StateT = TypeVar("StateT", bound=BaseModel)

Now that we have BaseTool[BaseModel, BaseModel] as a component, we get mypy errors when child classes pass types for ArgsT and ReturnT that are not specifically a BaseModel.

The fix will likely be to remove the contravariant=True but I am still thinking through side effects here (less flexibility for inheriting classes). Thoughts welcom.

Edit: Another (lighter) solution is to slightly relax the AssistantAgent tools type .. from List[BaseTool[BaseModel, BaseModel] to List[BaseTool[Any, Any] . It is already a very liberal type already (accepts CallableAny). Going with this!!

image

…[BaseTool[BaseModel, BaseModel] to List[BaseTool[Any, Any]
@victordibia victordibia merged commit 6702985 into main Jan 25, 2025
65 checks passed
@victordibia victordibia deleted the basetool_agentchat_vd branch January 25, 2025 20:04
@ekzhu
Copy link
Collaborator

ekzhu commented Jan 25, 2025

I think Any is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants