feat(mcp): auto_profile triggers on suggest_profile for with-query fetches#91
Merged
Merged
Conversation
…tches Telemetry (390 events, 2026-04-15~07-01) showed the suggest_profile hint fired 57 times on one nvidia forum URL with zero consumer profile_page calls — the hint mechanism works, consumers ignore it. Meanwhile the existing auto_profile inline generate-then-retry path only fired on queryless missing-profile calls, so it never engaged on that traffic. Changes: - auto_profile now also fires when a with-query full-pipeline result carries suggest_profile=true and no profile was used, reusing the same inline generate-then-retry flow (refactored into _auto_profile_generate_and_retry). - Env default TRAWL_MCP_AUTO_PROFILE=1 enables it deployment-wide; an explicit per-call auto_profile argument still overrides. - Guardrails (auto path only; explicit profile_page unaffected): process-lifetime failed-host cooldown, and an attempt cap TRAWL_MCP_AUTO_PROFILE_MAX (default 10, surfaced as auto_profile_skipped: cap_reached). - Default off: behavior byte-identical without env/arg. Motivating measurement: profiling the nvidia URL yields div.cooked, profile_direct path, total 7.9s -> 4.8s (-38.9%; retrieval+rerank eliminated). Gates: MCP stdio smoke OK; 7 new unit tests (trigger on/off, cooldown, cap) pass; /code-review low clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the ignored-hint gap found in the C4 telemetry analysis:
suggest_profilefired 57 times on one nvidia forum URL (visit threshold 3) with zero consumerprofile_pagecalls — the hint works, consumers ignore it. The existingauto_profileinline generate-then-retry path only engaged on query-less missing-profile calls, so it never fired on that traffic.Now
auto_profilealso fires when a with-query full-pipeline result carriessuggest_profile=trueand no profile was used, reusing the same inline flow. Deployment-wide enablement viaTRAWL_MCP_AUTO_PROFILE=1(per-call argument still overrides). Guardrails on the auto path only: process-lifetime failed-host cooldown + attempt capTRAWL_MCP_AUTO_PROFILE_MAX(default 10). Default off — behavior byte-identical without env/arg, preserving the CLAUDE.md ":8080 = bounded, manual-trigger" contract.Motivating measurement (in-container, fetch cache disabled): profiling the nvidia URL yields
div.cooked,profile_directpath, total 7.9s → 4.8s (−38.9%; retrieval+rerank eliminated).Gates
🤖 Generated with Claude Code