-
Notifications
You must be signed in to change notification settings - Fork 2
research(tools): tool dependency graph for sequential tool availability #2024
Copy link
Copy link
Closed
Labels
P2High value, medium complexityHigh value, medium complexityenhancementNew feature or requestNew feature or requestresearchResearch-driven improvementResearch-driven improvementtoolsTool execution and MCP integrationTool execution and MCP integration
Description
Context
Follow-up to #2020 (dynamic tool schema filtering). Community feedback from @Docat0209 highlighted an important gap: some tools become relevant only after other tasks complete.
Problem
Current filtering exposes tools in two states:
- Iteration 0: filtered by relevance (30-60% token savings ✓)
- Iterations 1+: full tool set available
This doesn't account for sequential dependencies. For example:
- Format results tool should only be visible after search succeeds
- Data validation tool should only be visible after data load completes
- Rollback tool should only be visible after operation attempt
Without explicit dependencies, LLM may request unavailable tools, wasting tokens and confusing the agent.
Solution
Implement a tool dependency graph to make tools conditionally available:
-
ToolDependency struct — define prerequisites
must_complete_before: tools that must finish firstworks_better_after: soft suggestions (for observability)
-
Dependency tracking — in Agent state
- Track completed tools in current conversation turn
- Query: "which tools are available?" based on completions
-
Enhanced filtering — combine relevance + dependencies
- Include tool if: (relevance match) OR (always_on) OR (dependency satisfied)
-
InclusionReason expansion
- Add:
DependencyMet(prerequisite completed) - Add:
DependencyNotMet(for logging why excluded)
- Add:
Implementation
- Keep dependencies optional (not all tools need them)
- Config:
[tool.<name>.dependencies]section - Testing: multi-turn scenarios with sequential tool chains
- UI: TUI status showing unavailable tools + unsatisfied dependencies
Acceptance Criteria
- Tool dependencies declared via config
- Unmet dependencies logged with clear reasons
- Tools with unsatisfied deps excluded from LLM schema
- No performance regression (dependency check < 10ms per turn)
- Integration tests verify multi-turn chains
- Docs updated (config schema, examples)
Labels
research, tools, enhancement
Related
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2High value, medium complexityHigh value, medium complexityenhancementNew feature or requestNew feature or requestresearchResearch-driven improvementResearch-driven improvementtoolsTool execution and MCP integrationTool execution and MCP integration