fix(agent-core): scope [image] config limits to the owning core#1521
Conversation
🦋 Changeset detectedLatest commit: 1020eb0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
7d17f88 to
e56d571
Compare
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d17f88dae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import { | ||
| MAX_IMAGE_EDGE_PX, | ||
| maxImageEdgeFromEnv, | ||
| READ_IMAGE_BYTE_BUDGET, | ||
| readImageByteBudgetFromEnv, | ||
| } from './image-compress'; |
There was a problem hiding this comment.
Export the env parsers before importing them
This new file is included by packages/agent-core/tsconfig.json's src include, but image-compress.ts does not export maxImageEdgeFromEnv or readImageByteBudgetFromEnv (repo-wide search only finds these names here). Any agent-core typecheck/build that loads src will fail on these missing exports before the package can ship.
Useful? React with 👍 / 👎.
| readImageByteBudgetFromEnv, | ||
| } from './image-compress'; | ||
|
|
||
| export class ImageLimits { |
There was a problem hiding this comment.
Wire ImageLimits into the compression pipeline
The resolver is added but never used: rg ImageLimits only finds this file, while KimiCore still calls the module-global setConfigured* setters and ReadMediaFile still resolves via resolveReadImageByteBudget(). In the multi-core scenario this change is meant to fix, constructing or reloading core B still restamps the global image config used by core A, so [image] limits remain process-global despite the changeset.
Useful? React with 👍 / 👎.
Problem
[image] max_edge_px/read_byte_budget(shipped in #1508) were pushed intomodule-global state via
setConfiguredMaxImageEdgePx/setConfiguredReadImageByteBudget, applied byKimiCoreon config load andreload. A second core constructed in the same process (the node-sdk's
multi-client pattern, or an embedded harness) restamps the module state, so
every existing session silently starts compressing images with another core's
settings. The same stamp-one-global pattern did not match the
experimental-flag resolver it was modeled on, whose config overrides live in a
per-core
FlagResolverinstance.What changed
ImageLimits— an owner-scoped resolver with the same lifecycle asFlagResolver: the owner creates one instance, pushes its config on loadand reload via
setConfig(), and consumers resolve through the instancethey were handed. Per value, precedence stays env var > owning config >
built-in default; the env vars stay process-level on purpose (operator
override), exactly like the experimental-flag env switches.
configured*variables are deleted.KimiCorecreates the instance,reloads push
setConfig(config.image), and it flowscore → Session → Agent(mirror ofexperimentalFlags\) into ReadMediaFile, the MCP output pipeline, and the core-process service for daemon-side ingestion (server prompt routes read it per request).ImageLimits` is exported fromthe package root.
resolveMaxImageEdgePx/resolveReadImageByteBudgetbecome env-only fallbacks for consumers thathave no config owner (TUI clipboard paste, ACP adapter), which is what those
processes already used in practice — the module stamp only ever ran
in-process of a core.
so a reloaded
[image]section takes effect on the next image read withouttouching the deprecated snapshot
kimiConfigon the Agent — that isdeliberately not the source, because it is frozen at construction time.
Tests
New coverage pins the regression itself and the reload semantics:
ImageLimitsunit tests: per-instance resolution, env-invalid fallback,setConfigreplace/clear, and two instances staying isolated.budget, one custom edge cap).
KimiCoreintegration: two cores with different[image]sections —reloading one does not restamp the other; a single core picks up
[image]changes on reload and falls back to built-ins when the section is removed.
Full monorepo typecheck, lint, and test suite pass; the only failures are 6
pre-existing
preflight.test.tscases that fail identically on the basebranch. Changeset included.