Skip to content

Conversational agent routing: one tool-calling co-pilot (answer-from-context vs delegate-to-Claude) #3

Description

@serge-ivo

Problem

The coding Agent chat has TWO explicit buttons — Send (always relays to Claude Code, expensive + side-effecting) and Status (always answers from context, cheap, read-only). That split is clunky: users shouldn't have to pre-classify their own message.

Approach (researched best practice)

Collapse to ONE chat backed by a single cheap co-pilot LLM running a tool-calling loop with three tools:

  • answer_from_context — default; it already holds the terminal + recent history.
  • search_history(query) — vector/semantic search over coding_timeline, on-demand (only when the question reaches past the in-window history). Not always-on context.
  • drive_claude(instruction) — the expensive, side-effecting delegation to Claude Code (the existing /message path); its "result" streams back into the same thread.

The LLM decides per message. No code words, no separate intent-classifier (only justified at hundreds of tools). This is the orchestrator-worker pattern Anthropic recommends for coding.

Prompt disposition: context-first, delegate on action — anything that changes files / runs commands / needs live repo state → drive_claude; otherwise describe from context.

Scope

  • Backend: turn /explain (or a new /agent) into a tool-calling loop (reuse BYOK Claude + the tool-loop machinery from the apply pipeline); add drive_claude (→ /coding/act) and search_history (→ coding_timeline + vectors) tools.
  • Frontend: fold Send + Status into one input; keep a thin /run or @claude override to force delegation.

Guard against

  • Under-delegation (cheap LLM answers a question it should have delegated) → hard prompt rule on action intent.
  • Over-delegation (wastes Claude on a status question) → make context-answer first-class.
  • Loop thrash → cap rounds + dedup identical tool calls (reuse existing 3-round cap).

Acceptance

  • One chat input. Typing "what's it doing?" answers from context; "add a test" drives Claude. @claude <x> always delegates. No double LLM cost on pure status questions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions