quick-window-91705
10/30/2025, 6:29 PMFinishTool = ToolDefintion(...) or subclasses BashTool(ToolDefinition): def create(...): ...
Thoughts on having all tools be a subclass of ToolDefinition instead of directly instantiating? That way every tool class can have a reliable name with which we can register and reference tools (e.g BashTool.name ) without having to actually instantiate the toolquick-window-91705
10/30/2025, 6:30 PMcreate method which raises a NotImplementedError , which is kinda hacky
The create method should be abstractmethod so that the contracts are not so ambiguouswooden-umbrella-84098
10/30/2025, 6:37 PMchilly-france-44439
10/30/2025, 7:16 PMThe instance level tools also have aThe reason why we needmethod which raises acreate, which is kinda hackyNotImplementedError
.create is because:
1. If we initialize ToolDefinition or its subclass directly, we need to pass in a executor= explictly -- and we'd like it keep it optional since 99% of the time, we don't need to share the executor between two tools
having all tools be a subclass ofthis could work, but given the above reason, we will need to keep theToolDefinition
.create() method which can returns an instance of that tool with tool executor populated thoughchilly-france-44439
10/30/2025, 7:16 PMquick-window-91705
10/30/2025, 7:20 PMclass FinishTool(ToolDefinition[FinishAction, FinishObservation]):
@classmethod
def create(cls, conv_state=None, **params) -> Sequence["FinishTool"]:
if params:
raise ValueError("FinishTool doesn't accept parameters")
return [cls(
name="finish",
action_type=FinishAction,
observation_type=FinishObservation,
description=TOOL_DESCRIPTION,
executor=FinishExecutor(),
annotations=ToolAnnotations(...)
)]
It requires a bit of overhead but has a predictable patternchilly-france-44439
10/30/2025, 7:23 PMTool, ToolDefinition, ToolBase in our system which makes thing a bit confusing
A few constraints i want to satisfy
1. The Tool we pass to Agent class needs to be serializable (since we will serialize Agent and send to remote conversation); And it should be lazy (when we pass arguments to the tool, it should NOT materialize -- it should only materialize when agent is initialized)
a. We can either keep it similar to current Tool which is a spec that handle .name and .params
b. Or we can figure out some hacks of ToolDefinition.create() so it returns some sort of future that's serializable, but not concrete Tool instance
2. We need at least two things: (1) a "spec"-verison of the tool that's serializable, (2) actual tool instance that can be execute (not serializable)
3. We should have the flexibility of decide whether to provider tool executor in tool initialization (e.g., in cases when we want to share the executor among multiple tool instances)nutritious-balloon-65098
10/30/2025, 7:23 PMnutritious-balloon-65098
10/30/2025, 7:29 PMToolDefinition architecture.
Key Findings
The current system has three overlapping concepts that create confusion:
1. Tool (spec.py): Serializable spec with name and params - passed to Agent class
2. ToolBase: Abstract base class with executor: ToolExecutor | None and abstract .create() method
3. ToolDefinition: Concrete implementation that raises NotImplementedError in .create()
Two problematic patterns exist:
• Direct instances: FinishTool = ToolDefinition(...) with executor already set
• Subclasses: class BashTool(ToolDefinition): ... with custom .create() implementation
This inconsistency makes the contract ambiguous and leads to the hacky NotImplementedError for built-in tools.
Issue Created
GitHub Issue #970: Proposal: Simplify `ToolDefinition` Architecture
The issue includes:
• Problem Statement: Detailed explanation of the confusion and inconsistency
• Current Architecture: Code examples showing both patterns
• Constraints to Satisfy: The three requirements you specified (serializable/lazy, two-level architecture, flexible executor initialization)
• Proposed Solution: Make all tools subclasses with .create() as @abstractmethod
• Example Refactoring: Before/after code showing how to convert FinishTool from direct instance to subclass
• Benefits: 6 key advantages including predictable pattern, clear contract, type safety
• Alternative Considered: Proxy/future pattern and why the subclass approach is better
• Implementation Plan: 5-step roadmap
• Open Questions: 3 discussion points for backward compatibility and naming
The issue has been tagged with enhancement and architecture labels and is ready for team discussion.
<sub>View full conversation</sub>chilly-france-44439
10/30/2025, 7:39 PMToolDefinition.create() so it returns some sort of future that's serializable, but not concrete Tool instance"? do we still need to keep Tool as spec?nutritious-balloon-65098
10/30/2025, 7:39 PMnutritious-balloon-65098
10/30/2025, 7:40 PMTool as spec?
A: Yes, we absolutely still need Tool as the serializable spec. The subclass pattern addresses a different problem:
• Subclass pattern solves: Inconsistent tool definition patterns (direct instances vs subclasses) and ambiguous .create() contracts
• Does NOT solve: Serialization and lazy loading requirements
The two-layer architecture remains necessary:
1. Tool (spec.py): Serializable spec with name + params - passed to Agent class
2. ToolDefinition (subclasses): Executable instances with executors - materialized during agent initialization
The subclass pattern makes the second layer consistent and predictable, but doesn't eliminate the need for the first layer. Your constraint 1a (keep current Tool spec) is still the approach, not 1b (making ToolDefinition itself serializable as a "future").
Issue Created
The GitHub issue comprehensively documents:
• Current architecture and its problems
• All three constraints you specified
• Proposed solution with examples
• Benefits, alternatives, and implementation plan
• Open questions for team discussion
No code changes were made - this was purely an exploratory and documentation task.
<sub>View full conversation</sub>chilly-france-44439
10/30/2025, 7:56 PMclass FinishTool(ToolDefinition[FinishAction, FinishObservation]): workschilly-france-44439
10/30/2025, 7:58 PMchilly-france-44439
10/30/2025, 7:58 PMquick-window-91705
11/03/2025, 5:15 PMchilly-france-44439
11/03/2025, 5:21 PMchilly-france-44439
11/03/2025, 5:21 PMquick-window-91705
11/03/2025, 5:29 PMchilly-france-44439
11/03/2025, 5:31 PMchilly-france-44439
11/03/2025, 5:32 PMchilly-france-44439
11/03/2025, 5:32 PMchilly-france-44439
11/03/2025, 5:33 PMquick-window-91705
11/03/2025, 6:04 PMToolBase to just be Tool could help simplify thingschilly-france-44439
11/03/2025, 8:38 PM