Skip to content

fix(codemode): reuse tool discovery catalogs - #49276

Merged
thdxr merged 1 commit into
v2from
memory-tuning
Sep 16, 2026
Merged

thdxr merged 1 commit into
v2from
memory-tuning

Conversation

@thdxr

@thdxr thdxr commented Sep 16, 2026

Copy link
Copy Markdown
Member

Issue for this PR

N/A — memory profiling follow-up.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Reduce repeated tool-discovery allocation:

  • Reuse one rendered catalog per Location while the registry revision and visible tools match. Registration changes invalidate it; executable definitions stay request-local.
  • Build the catalog/search index on demand, so known tool calls skip discovery work.
  • Render signatures only for returned search matches, share descriptions between catalog and search, and join final signature fragments to avoid retaining intermediate string ropes.

Only three production files are included.

How did you verify your code works?

After rebasing onto the latest Code Mode hooks refactor:

  • bun run check
  • All 1,267 Code Mode tests
  • 368 focused Core registry, catalog, MCP, and session-runner tests
  • Independent background review found no actionable production regressions

A local compiled-server stress benchmark (median of three pairs, Bun --smol in both) used two Locations, four concurrent sessions, 400 schema-heavy fixture tools, 32 prompts, 64 model steps, 32 successful tool calls, and eight searches:

Metric Before After
Peak RSS 1,388 MiB 642 MiB
RSS at final prompt batch 1,165 MiB 488 MiB
RSS after three seconds idle 828 MiB 488 MiB
Workload time 17.9 s 5.1 s

The deterministic localhost model and constant-result tool emphasize server processing overhead. These are synthetic stress-workload measurements, not an end-to-end inference speedup claim.

Screenshots / recordings

N/A — runtime allocation changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

from OpenCode

@thdxr
thdxr merged commit 5379a2d into v2 Sep 16, 2026
10 checks passed
@thdxr
thdxr deleted the memory-tuning branch September 16, 2026 04:52
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