Problem
sessionDefaults.simulatorPlatform is declared as a session default (see src/utils/session-defaults-schema.ts:35-38, described as "Cached inferred simulator platform"), but it does not behave like one.
Session defaults are meant to be values an agent sets to influence tool calls. simulatorPlatform violates that contract:
- It is written automatically by
src/utils/simulator-defaults-refresh.ts (lines 80, 87) as a side effect of resolving a simulator — not by an agent.
- It is keyed to another default (
simulatorId / simulatorName) and only trusted when those still match (src/utils/infer-platform.ts:113-139, resolveCachedPlatform).
- Its sole consumer is
infer-platform.ts, which uses it to skip a simctl list round-trip.
In other words, it is internal cache state surfaced through the agent-facing session-defaults schema. Agents that read or write sessionDefaults see a field they should not be touching, and any code that legitimately wants to set a project's "platform" preference (e.g. the setup wizard in #365) gets pulled into caching semantics it does not want.
Proposed direction
Two reasonable options:
- Move it to a separate internal cache that is not part of
sessionDefaults and is not exposed via session_set_defaults / session_show_defaults / session_clear_defaults. infer-platform.ts and simulator-defaults-refresh.ts become the only readers/writers.
- Drop the cache entirely and re-derive the simulator platform on demand from
simulatorId via simctl list. Costs one extra lookup per fresh session; removes a whole class of staleness bugs.
Option 1 preserves the perf optimisation; option 2 is simpler. Either is fine — the key constraint is that simulatorPlatform should not be in sessionDefaults.
Out of scope
Affected files (current state)
src/utils/session-defaults-schema.ts — declares the field
src/utils/simulator-defaults-refresh.ts — writer
src/utils/infer-platform.ts — reader
src/mcp/tools/session-management/session_*.ts — surfaces it to agents
src/utils/renderers/domain-result-text.ts, src/types/domain-results.ts — render/type plumbing
Problem
sessionDefaults.simulatorPlatformis declared as a session default (seesrc/utils/session-defaults-schema.ts:35-38, described as "Cached inferred simulator platform"), but it does not behave like one.Session defaults are meant to be values an agent sets to influence tool calls.
simulatorPlatformviolates that contract:src/utils/simulator-defaults-refresh.ts(lines 80, 87) as a side effect of resolving a simulator — not by an agent.simulatorId/simulatorName) and only trusted when those still match (src/utils/infer-platform.ts:113-139,resolveCachedPlatform).infer-platform.ts, which uses it to skip asimctl listround-trip.In other words, it is internal cache state surfaced through the agent-facing session-defaults schema. Agents that read or write
sessionDefaultssee a field they should not be touching, and any code that legitimately wants to set a project's "platform" preference (e.g. the setup wizard in #365) gets pulled into caching semantics it does not want.Proposed direction
Two reasonable options:
sessionDefaultsand is not exposed viasession_set_defaults/session_show_defaults/session_clear_defaults.infer-platform.tsandsimulator-defaults-refresh.tsbecome the only readers/writers.simulatorIdviasimctl list. Costs one extra lookup per fresh session; removes a whole class of staleness bugs.Option 1 preserves the perf optimisation; option 2 is simpler. Either is fine — the key constraint is that
simulatorPlatformshould not be insessionDefaults.Out of scope
sessionDefaults.platform— that one is a legitimate agent-controllable default for device tools and should stay.Affected files (current state)
src/utils/session-defaults-schema.ts— declares the fieldsrc/utils/simulator-defaults-refresh.ts— writersrc/utils/infer-platform.ts— readersrc/mcp/tools/session-management/session_*.ts— surfaces it to agentssrc/utils/renderers/domain-result-text.ts,src/types/domain-results.ts— render/type plumbing