Skip to content

Advertise present, manage_goal, manage_tasks, and lsp conditionally - #357

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-5588-conditional-tools
Aug 7, 2026
Merged

Advertise present, manage_goal, manage_tasks, and lsp conditionally#357
TheGreatAxios merged 1 commit into
mainfrom
cl-5588-conditional-tools

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • present is removed from the advertised core set entirely; it stays fully dispatchable and is discovered via tool_search — at 2,793 chars it was the second-largest schema on the wire for a feature most sessions never use.
  • manage_goal is advertised only when the session was resumed with an already-active/paused/budget-limited goal (checked once via loadGoalState before the first inference call), not whether a goal exists at the current instant.
  • lsp is advertised only when a language server was resolvable for the project at startup (src/agent/lsp-availability.ts mirrors @intx/tools-lsp's TypeScript server check: a resolvable tsserver plus a reachable typescript-language-server binary), not whether one currently responds.
  • manage_tasks stays unconditionally advertised in both session modes. goalKickoffUserMessage (src/agent/goal.ts) instructs the model to call manage_goal then manage_tasks back to back whenever a goal starts — gating the second would trade one tool_search round trip for two, which is the exact failure shape task/search_agents were promoted into the core set to avoid.
  • ask_operator is untouched.

All four conditions are resolved once per session, before the toolset is built, and threaded through as an explicit ToolAvailability value (hasGoalAtLaunch, languageServerAvailable) rather than re-derived mid-session, since the tools array is a provider cache prefix.

Verification

  • bun run typecheck, bun run test (3957 pass), and bun run build all pass.
  • New/updated tests in src/agent/tool-search.test.ts cover: present absent from the core set, manage_goal/lsp gated on availability, manage_tasks/ask_operator advertised unconditionally, and the built-in prefix staying byte-identical across repeated calls with the same session-start availability (simulating turns).
  • New src/agent/lsp-availability.test.ts covers detectLanguageServerAvailable against a seeded temp project and against this repo's own checkout.
  • Measured in-repo: an orchestrator session with none of the four gated tools applicable drops the advertised tool-schema JSON from 18,366 to 12,948 chars (~4,592 to ~3,237 tokens at the chars/4 lower bound) — a 5,418-char (~1,355-token) reduction, on top of removing present from every session regardless of gate state.

Closes CL-5588

Tradeoff: manage_goal is gated on whether a goal exists at session start, so
a goal set mid-session costs one tool_search round trip before the model can
call it. Most sessions neither start with nor acquire a goal, and the wire
array must stay fixed for the prompt cache, so this is the intended trade
rather than an oversight.

present now stays fully dispatchable but is discovered via tool_search
instead of riding every request at 2,793 chars — the second-largest
core tool schema for a feature most sessions never touch.

manage_goal is advertised only when the session was resumed with an
already-active goal, and lsp only when a language server was resolved
at startup. Both facts are captured once, before the first inference
call, since the wire tools array is a provider cache prefix: toggling
either mid-session would force a re-prefill worse than the schema
bytes saved. manage_tasks stays unconditional in both session modes —
the goal-kickoff sequence calls manage_goal then manage_tasks back to
back, so gating the second would trade one tool_search round trip for
two.
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

CL-5588

@TheGreatAxios
TheGreatAxios merged commit 2084430 into main Aug 7, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant