Skip to content

fix: expose active model in stable prompts - #3613

Merged
Astro-Han merged 3 commits into
apache:mainfrom
Astro-Han:fix/session-model-context
Aug 23, 2026
Merged

fix: expose active model in stable prompts#3613
Astro-Han merged 3 commits into
apache:mainfrom
Astro-Han:fix/session-model-context

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose the active execution model once in the stable interactive system prompt for main, child, and hosted headless/Eval runs
  • keep the per-turn session environment focused on volatile context and rely on the existing backend rebuild to refresh identity after a model switch
  • collapse the model-switch transcript projection to the latest assistant model and remove unused session-change payload fields

The model identity is intentionally not persisted as a switch event: the Session header remains the current configuration authority, assistant messages record the model actually used by each completed step, and changing the model already disposes the backend before the next prompt is composed.

Verification

  • npm run build
  • npm --workspace @maka/core run build
  • node --test packages/core/dist/__tests__/model-switch-transcript.test.js
  • npm --workspace @maka/runtime run build
  • npm --workspace @maka/runtime-host run build
  • node --test --test-name-pattern='child prompts identify the active model|backend composition survives a moved saved Git Bash executable while Bash fails closed' packages/runtime-host/dist/__tests__/execution-model-composition.test.js
  • npx tsc -p apps/desktop/tsconfig.main.json --noEmit
  • npx tsc -p apps/desktop/tsconfig.preload.json --noEmit
  • npx tsc -p apps/desktop/tsconfig.renderer.json --noEmit
  • Biome format check on affected source and test files
  • git diff --check

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Maka diagnosed the prompt/event-log composition, authored the implementation and tests, and ran the focused validation. The human contributor will review the final diff and owns the merge decision.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@Astro-Han
Astro-Han force-pushed the fix/session-model-context branch from dbce799 to 83e604a Compare August 23, 2026 13:22
@Astro-Han
Astro-Han marked this pull request as ready for review August 23, 2026 14:06

@Astro-Han Astro-Han left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: NO-GO (1×P1)

The ordinary main/child composer path is sound: modelId is captured when the backend is built, a configuration transition disposes that backend before committing the new model, and the new line is therefore stable for the lifetime of each composer. Switching models does not create an additional useful-prefix-cache loss because the request is moving to a different model authority anyway. The transcript projection and session-change payload deletions are also behavior-preserving: hasConversation and ordinary-update connectionSlug/modelId had no consumers, while rebound events retain modelId.

P1 — the first-class headless/Eval prompt still omits the active model

createInteractiveRunComposer returns the tool-profile prompt at packages/runtime-host/src/server/interactive-run-composer.ts:219-228, before buildActiveModelPromptFragment(input.model) is reached at :255. Production still passes both toolProfile: 'headless-coding-v1' and the selected modelId through the same factory (:474-511), so every Maka Eval/hosted headless run receives the old four-line prompt with no model identity. This is a supported production surface, not a test-only branch: packages/eval/src/maka-subject.ts:56 publishes the configured tool profile and Maka Eval fixtures use headless-coding-v1.

I reproduced the exact branch on this head by constructing the composer with both toolProfile: 'headless-coding-v1' and model: 'fixture-model'; resolveSystemPrompt returned containsActiveModel: false. The existing freeze test at execution-model-composition.test.ts:2980-3025 also asserts the old exact prompt and never supplies a model, so CI cannot catch the omission. As written, the PR's unqualified contract—expose the active execution model once in the stable interactive prompt—does not hold for the product's hosted execution path.

Please compose the normalized model identity into the profiled stable prompt too, and add a regression that supplies model while using headless-coding-v1. Keep the profile's fixed tool ceiling and avoid reading Skills/Memory; only its stable prompt text needs the identity.

Validation: exact-head CI run 32642142585 and Windows package run 32642142543 are terminal success on 83e604a3ee188c94f2af99ab704313e842ddab29. Clean dependency-order Core → Runtime → Storage → Runtime Host builds passed locally; focused transcript tests passed 2/2 and prompt/profile tests passed 3/3. The initial Runtime Host-only build failure was stale local Storage declarations and disappeared after building Storage; it is not a PR finding.

@Astro-Han
Astro-Han force-pushed the fix/session-model-context branch from 83e604a to fcb8917 Compare August 23, 2026 14:32
Prepend the selected model at the Runtime Host execution boundary after final target resolution. This keeps interactive composers model-agnostic while ensuring main, child, and headless provider requests share one stable execution identity.

Generated-by: Maka
Return the latest assistant model directly instead of maintaining an unused conversation-presence field and object wrapper. The renderer only needs the latest actual model for switch feedback.

Generated-by: Maka
Session change events invalidate renderer projections and correlate turn lifecycle changes. Remove the unused connection slug field and stop attaching model details to ordinary model-update invalidations; modelId remains only for rebound feedback.

Generated-by: Maka
@Astro-Han
Astro-Han force-pushed the fix/session-model-context branch from fcb8917 to e7eab01 Compare August 23, 2026 14:53

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GO on exact head e7eab01.

The prior headless/Eval blocker is closed by the single outer injection point in createHostAiSdkBackend: every resolved system prompt now receives the normalized, already-authorized execution model. resolveExecutionTarget() rejects empty and unauthorized models before this path, and session model changes dispose the existing backend before committing the new header, so the identity is stable within one backend/prefix-cache lifetime.

The production hosted-execution wire test covers toolProfile: headless-coding-v1 plus an explicit model target, checks the active-model bytes and updated prompt hash, and passed locally. Removing the injection made that test fail at the active-model assertion. The transcript projection and session-change payload reductions are behavior-preserving and remove unused projections. No P0-P3 findings remain; exact-head hosted test and package are completed/success.

Execution provenance: acting under @WAWQAQ standing Maka review/action authorization; scope: technical review and APPROVE only; exact head: e7eab01. No merge performed.

@Astro-Han
Astro-Han merged commit cd0163a into apache:main Aug 23, 2026
2 checks passed
@Astro-Han
Astro-Han deleted the fix/session-model-context branch August 23, 2026 15:14
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.

2 participants