fix(discovery): keep eval imports and repeated discovery off the agent run path - #4556
Conversation
…t run path ensureProjectDiscovery imported every evals/*.eval.ts module on each agent run and resume, although runs never use evals and eval execution discovers them itself. A project whose evals read fixtures by a CWD-relative path failed those imports in production, and because any per-file error evicted the discovery cache, every turn paid full rediscovery (~10s through the proxy file system). The run path now discovers with no eval directories; the configured evalDirs still mark those directories server-only for browser module admission and hosted executor roots. A production release keeps a result with errors for a 60s retry window instead of evicting it, so a defect in an immutable release costs one discovery per window while a transient read failure still gets retried. Mutable sources keep retrying at once. Refs veryfront/veryfront-issue-inbox#1620
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Warning Review limit reachedNext included review available in 45 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
📦 Client bundle boundary
A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in |
Code ReviewScore: 87/100 — Good: a well-scoped, well-reasoned fix with meaningful regression tests; a couple of minor polish points, no blockers. Strengths
Minor points (non-blocking)
Nothing here blocks merge — this is a solid, surgical fix for a real production latency issue with good test coverage. Generated by Claude Code |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
|
Score: 93/100 Reviewed exact head: b15292a Why:
Minor deduction: the module-level test clock seam is global state, so future parallelization of this suite would need care. This is test-only risk and does not block merge. Recommendation: merge. |



Fixes veryfront/veryfront-issue-inbox#1620.
Problem
Every agent run turn for
agentic-email-processing-outlookspent ~10s betweenAccepted internal agent stream requestandStarting internal agent runtime stream. Each turn loggedPrimitive discovery completed with errors(agents 5, errors 12), and every parent resume after aninvoke_agentpark paid it again.Two causes in
ensureProjectDiscovery:src/eval/discovery.ts). This project'sevals/mock-tools.tsreadsknowledge/email-categories.mdby a CWD-relative path at import time, so 12 eval imports fail withENOENTwherever the CWD isn't the project root.Local reproduction
I ran the production discovery path (
ensureProjectDiscovery, release-scoped, real local adapter) three times against the actual project source, with the CWD outside the project:ENOENT … 'knowledge/email-categories.md'fromevals/*.eval.ts)Locally a rediscovery costs ~150 ms. In production each one reads the project through the proxy file system.
Change
discoverAllwithevalDirs: []. The configuredevalDirsare unchanged, so browser module admission and hosted executor roots still treatevals/as server-only.PRODUCTION_DISCOVERY_ERROR_RETRY_MS(60s) instead of evicting it. A release can't change, so a defect costs one discovery per window, and a transient read failure is still retried after the window. Mutable sources (preview) keep retrying immediately; the existing "retries partial discovery within the same source snapshot" test still passes.Tests
does not import eval modules on the run path;reuses a production release discovery with errors until its retry window ends(clock injected via__setProjectDiscoveryClockForTests).project-discovery.test.tspasses (27 steps), and so doproject-run-execute.handler,api-handler-wrapper,agent-stream.handler,discovery/index,auto-discovery.integrationandeval/discovery.deno check,deno lintanddeno fmtare clean on the changed files.