Skip to content

research(tools): tool dependency graph for sequential tool availability #2024

@bug-ops

Description

@bug-ops

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:

  1. ToolDependency struct — define prerequisites

    • must_complete_before: tools that must finish first
    • works_better_after: soft suggestions (for observability)
  2. Dependency tracking — in Agent state

    • Track completed tools in current conversation turn
    • Query: "which tools are available?" based on completions
  3. Enhanced filtering — combine relevance + dependencies

    • Include tool if: (relevance match) OR (always_on) OR (dependency satisfied)
  4. InclusionReason expansion

    • Add: DependencyMet (prerequisite completed)
    • Add: DependencyNotMet (for logging why excluded)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2High value, medium complexityenhancementNew feature or requestresearchResearch-driven improvementtoolsTool execution and MCP integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions