feat: add id to Toolkit#8724
Conversation
Add an id field to the base Toolkit class. When not provided, the id is generated deterministically from the toolkit name via generate_id_from_name, mirroring how Agent, Team, and Workflow derive their ids.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1365f52971
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def __init__( | ||
| self, | ||
| name: str = "toolkit", | ||
| id: Optional[str] = None, |
There was a problem hiding this comment.
Keep id keyword-only to preserve positional tools
When existing callers use the old public constructor form Toolkit("math", [add]), the second positional argument now binds to id instead of tools, so the toolkit silently registers no functions and stores the list as its id. This is a backwards-incompatible runtime regression for any positional tools callers; add id after the existing positional parameters or make it keyword-only.
Useful? React with 👍 / 👎.
Summary
Adds an
idfield to the baseToolkitclass so every toolkit has a stable identifier.id: Optional[str] = Noneparameter onToolkit.__init__.idis generated deterministically fromnameviagenerate_id_from_name, mirroring howAgent,Team, andWorkflowderive their ids.idis included inToolkit.__repr__.Because all built-in toolkit subclasses forward
**kwargstosuper().__init__,idcan be set on any toolkit (e.g.Calculator(id="...")) without further changes.Type of change
Checklist
./scripts/format.shand./scripts/validate.sh)Duplicate and AI-Generated PR Check
Additional Notes
The
idparameter is inserted as the second positional argument (aftername). All toolkit subclasses callsuper().__init__with keyword arguments, so this ordering does not break any existing call site. Added unit tests covering auto-generated id, explicit id, and id in repr.