Production SEARCH_TOOLS traces show two sequential getToolFromThermosWithDetails calls per request:
checkEnabledToolsForSession (~30-60ms) — validates plan / hybrid candidate slugs against session restrictions. Returns {enabled: Record<slug, boolean>} and throws away the rest of the Thermos response.fetchToolSchemas (~30-50ms) — re-fetches the SAME slugs (a subset of the candidates from step 1) to extract description + request_schema for the SDK response.The Thermos endpoint already returns {slug, toolkit_slug, tags, description, request_schema} in a single call — we just discard 80% of the response in step 1 and re-fetch in step 2. In the median p50=2056ms trace, this redundant round-trip costs ~33ms; at p90 it costs more.
Thread a request-scoped schemaPrefetch: Map<string, PrefetchedToolDetails> through SearchContext. checkEnabledToolsForSession populates it opportunistically with the full Thermos response (no extra fetch). fetchToolSchemas consults it first and only fetches slugs that are missing.
This is NOT a cross-request cache — the map is created per search request inside prepareSearchContext{,ForToolRouter}, lives entirely on the call stack, is mutated in place by the search-time validator, and is never read across requests. We are just plumbing data we already fetched within the same request.
Behavior is unchanged when the prefetch map is empty / not supplied (no session restrictions, no LD flag, etc.) — the existing Thermos call runs as before.
Unit tests (9 new, all passing):
check_enabled_tools_for_session.test.ts:
fetchToolSchemas_prefetch.test.ts:
Existing tests (all still passing):
checkEnabled.test.ts (9 tests)search.hybrid_disabled_tools_filter.test.ts (1 test)fuzzy_slug_match.test.ts (suite)search_result_utils.test.ts (large suite)searchRace.test.ts + prepareSearchContextForToolRouter.test.ts (12 tests)composio_actions/utils/** — 192 tests passed.pnpm check-types clean. pnpm lint clean for changed files.
E2E: Apollo restarted on the new code, healthcheck OK, and a tool-router session was created + COMPOSIO_SEARCH_TOOLS was invoked against it. The local search infra returns empty results (known limitation per /workspace/CLAUDE.md — Thermos lacks sort_by=usage data locally), but the code path compiles, type-checks, and the unit tests cover the prefetch lookup behavior directly.
Estimated savings: ~30-50ms per SEARCH_TOOLS request when (a) filter_disabled_tools_in_search LD flag is on AND (b) the session has any toolkit/tool/tag restriction (the production-common case). Applies to both plan-search-won and tool-search-won paths because checkEnabledToolsForSession is invoked along both.
Origin: cron-1b67184aec75 / zen-cron-3f3e44aa1a4f Triggered by: dhawal@composio.dev | Source: cron Session: https://zen-api-production-4c98.up.railway.app/dashboard/#/chat/zen-cron-3f3e44aa1a4f
Based on git blame analysis of 9 file(s):
| Contributor | Contribution | Files |
|---|---|---|
| Dhawal Upadhyay | 64% | 7 |
| Zen | 20% |
| 9 |
| Jayesh Sharma | 13% | 6 |
| abir-taheer | 1% | 3 |
| lingalarahul7 | 1% | 3 |
Recommend Zen and Dhawal Upadhyay. Zen made several edits today (including tests and tooling files) and can quickly review recent changes; Dhawal is the primary author on the large search/orchestrator/vector_search files and has deep context to validate logic and integration.
🤖 Based on git blame with recency weighting (recent edits count more).
:x: Patch coverage is 95.52239% with 3 lines in your changes missing coverage. Please review.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...ib/composio_actions/actions/search_result_utils.ts | 95.23% | 2 Missing :warning: |
| ...composio_actions/utils/planSearch/vector_search.ts | 0.00% | 1 Missing :warning: |
| Flag | Coverage Δ | |
|---|---|---|
| e2e-tests | 6.04% <2.98%> (-0.01%) | :arrow_down: |
| self-hosted-tests | 5.59% <2.98%> (-0.01%) | :arrow_down: |
| thermos-unit-tests | ? | |
| unit-tests | 58.70% <95.38%> (+<0.01%) | :arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| .../src/lib/composio_actions/actions/search_action.ts | 74.48% <100.00%> (+0.26%) | :arrow_up: |
| ...ib/composio_actions/actions/search_orchestrator.ts | 80.19% <100.00%> (+0.07%) | :arrow_up: |
| ...src/lib/composio_actions/utils/planSearch/types.ts | 100.00% <ø> (ø) | |
| ...lo/src/lib/composio_actions/utils/search_engine.ts | 75.97% <100.00%> (+0.12%) | :arrow_up: |
| .../features/tools/check_enabled_tools_for_session.ts | 87.64% <100.00%> (+0.81%) | :arrow_up: |
... and 267 files with indirect coverage changes
27.96% <0.00%> (-0.05%) |
| :arrow_down: |
| ...ib/composio_actions/actions/search_result_utils.ts | 95.24% <95.23%> (+0.46%) | :arrow_up: |