fix(eve): resolve code-defined model imported from a sibling module in dev#140
Open
dang-w wants to merge 1 commit into
Open
fix(eve): resolve code-defined model imported from a sibling module in dev#140dang-w wants to merge 1 commit into
dang-w wants to merge 1 commit into
Conversation
…n dev
Source-backed model resolution loaded the compiled module map by importing
`module-map.mjs` directly, which skips the authored-source loader the rest of
the dev runtime uses. For an agent whose `model` is a code-defined provider
object (e.g. `anthropic("claude-opus-4-8")`) imported from a sibling module
via a NodeNext `.js` specifier, re-importing the agent config at turn time
could not resolve the `.js` specifier to its `.ts` source and failed with
`LoadCompiledModuleMapError`. `eve build` / `eve start` were unaffected
because the bundler resolves the import graph at build time.
Route source-backed model resolution through a shared
`loadRuntimeCompiledModuleMap` — the same authored-source-aware loader the
compiled-agent cache already uses — so both paths resolve modules
identically, and remove the now-duplicated loader from the cache.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Dan Walsh <hello@danwalsh.co>
|
@dang-w is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
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.
Fixes #92.
Problem
eve dev(and thereforeeve eval, which runs through the dev runtime) fails at turntime with
LoadCompiledModuleMapErrorwhen an agent'smodelis a code-defined providerobject (e.g.
anthropic("claude-opus-4-8")) imported into the agent config from asibling module:
eve build+eve startresolve the same agent fine; only the dev runtime is affected.Root cause
A non-string
modelcan't be serialised into durable state, so it becomes a source-backedmodel reference that is re-imported at turn time to read
.modelback out(
resolve-model.ts→loadSourceBackedRuntimeModelReference). That path called the basicloadCompiledModuleMapdirectly, which importsmodule-map.mjsand re-imports theauthored config from raw
.tssource — without the NodeNext.js→.tsspecifier mapping.Meanwhile the normal agent-loading path (
compiled-agent-cache.ts) already branches onmoduleMapLoaderPathand uses the authored-source loader (loadAuthoredModuleNamespace)in dev, which resolves those specifiers correctly. The two paths diverged; the model
resolver used the wrong one.
Fix
Extract that branching logic into a single shared
loadRuntimeCompiledModuleMapinruntime/loaders/module-map.ts, and route both the compiled-agent cache and source-backedmodel resolution through it. So a code-defined model imported from a sibling module now
resolves identically in dev and production. Net change is a small consolidation
(+49/−39) that removes the duplicated loader.
Verification
eve initapp withexport const model = anthropic("claude-opus-4-8")inagent/lib/models.ts, imported byagent/agent.ts, failson
eve evalbefore this change. After it, model resolution succeeds and the run proceeds tothe actual model call (no more
LoadCompiledModuleMapError).runtime/agent/resolve-model.test.ts): asserts source-backedmodel resolution loads the module map through
loadRuntimeCompiledModuleMap(theauthored-source-aware loader), not
loadCompiledModuleMap. It fails on the previous code andpasses on the fix. (A note on why it's a unit test: the runtime failure only reproduces under
real Node — vitest's loader transparently remaps
.js→.ts, so an end-to-end scenario testpasses either way and can't guard this regression. The unit test pins the loader the resolver
must use.)
typecheck,build, and the existing scenario + integration tests forthe authored-source loading path (
authored-module-loader.scenario,cache-key.scenario,dev-runtime-artifacts.integration) all pass.patch).