Skip to content

Move simulatorPlatform out of sessionDefaults into an internal cache #366

@cameroncooke

Description

@cameroncooke

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:

  1. 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.
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions