Skip to content

fix(eve): resolve code-defined model imported from a sibling module in dev#140

Open
dang-w wants to merge 1 commit into
vercel:mainfrom
dang-w:fix/dev-source-backed-model-resolution
Open

fix(eve): resolve code-defined model imported from a sibling module in dev#140
dang-w wants to merge 1 commit into
vercel:mainfrom
dang-w:fix/dev-source-backed-model-resolution

Conversation

@dang-w

@dang-w dang-w commented Jun 20, 2026

Copy link
Copy Markdown

Fixes #92.

Problem

eve dev (and therefore eve eval, which runs through the dev runtime) fails at turn
time with LoadCompiledModuleMapError when an agent's model is a code-defined provider
object
(e.g. anthropic("claude-opus-4-8")) imported into the agent config from a
sibling module:

LoadCompiledModuleMapError: Cannot find module '.../source/agent/lib/models.js'
  imported from '.../source/agent/agent.ts'

eve build + eve start resolve the same agent fine; only the dev runtime is affected.

Root cause

A non-string model can't be serialised into durable state, so it becomes a source-backed
model reference
that is re-imported at turn time to read .model back out
(resolve-model.tsloadSourceBackedRuntimeModelReference). That path called the basic
loadCompiledModuleMap directly, which imports module-map.mjs and re-imports the
authored config from raw .ts source — without the NodeNext .js.ts specifier mapping.

Meanwhile the normal agent-loading path (compiled-agent-cache.ts) already branches on
moduleMapLoaderPath and 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 loadRuntimeCompiledModuleMap in
runtime/loaders/module-map.ts, and route both the compiled-agent cache and source-backed
model 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

  • Repro fixed end-to-end. A fresh eve init app with export const model = anthropic("claude-opus-4-8") in agent/lib/models.ts, imported by agent/agent.ts, fails
    on eve eval before this change. After it, model resolution succeeds and the run proceeds to
    the actual model call (no more LoadCompiledModuleMapError).
  • Regression test added (runtime/agent/resolve-model.test.ts): asserts source-backed
    model resolution loads the module map through loadRuntimeCompiledModuleMap (the
    authored-source-aware loader), not loadCompiledModuleMap. It fails on the previous code and
    passes 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 test
    passes either way and can't guard this regression. The unit test pins the loader the resolver
    must use.)
  • No regressions. typecheck, build, and the existing scenario + integration tests for
    the authored-source loading path (authored-module-loader.scenario, cache-key.scenario,
    dev-runtime-artifacts.integration) all pass.
  • Changeset included (patch).

…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>
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@dang-w is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

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.

eve dev fails every turn with LoadCompiledModuleMapError when the agent uses a code-defined (direct-provider) model

1 participant