Skip to content

fix(kas): start sub-agent and step sessions on kiro-cli's default model - #36661

Merged
bolichen97 merged 2 commits into
mainfrom
fix/33744-kas-default-model-shared-sessions
Nov 19, 2026
Merged

bolichen97 merged 2 commits into
mainfrom
fix/33744-kas-default-model-shared-sessions

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A KAS sub-agent that shares its parent's process, and a workflow run's planner, step and review sessions, start on kiro-cli's chat.defaultModel when nothing pins a model, the way a KAS chat already does.

On a KAS runtime, a shared sub-agent session and a workflow run's per-step session are created with no model step, so they run on KAS's own default model even when the operator set chat.defaultModel in kiro-cli. The same work on kiro-cli, and a KAS chat since #34155, run on that setting.

Why it matters

An operator who picked a default model in kiro-cli gets a different model, with a different cost and quality, for every KAS sub-agent and workflow step than for their chats, with nothing on screen saying so.

Not a goal

  • Applying an agent spec's own model, or Kiro Crew's own default model, to a KAS shared session: such a session is left on KAS's default, as it is today.
  • A warm-pool process started in another folder.
  • The KAS chat start and a warm worker's fresh conversation (fix(kas): start an unpinned kas chat on kiro-cli's chat.defaultModel #34155 covers both).
  • Any change to kiro-cli sessions, which read cli.json themselves.

What changed (motivation → approach → change)

On a KAS runtime, a shared sub-agent session and a workflow step session start on the chat.defaultModel of the folder they run in, as an inherited model, the way the KAS chat start does.

Symptom: these two sessions ran on KAS's own default model, not the operator's kiro-cli chat.defaultModel. Cause: #34155 put the model step in the chat's cold start (providers/acp_runtime_start.py) only. These two sessions are created straight on an already-running runtime with runtime.create_session(...), and nothing after that applies a model.

Change: one async helper, serve_kiro_cli_default_model(runtime, handle, work_dir, agent_model), in a new agent_sdk/kas_default_model.py (the agent_sdk boundary, since check_agent_sdk_boundary.py refuses a new kiro_crew.acp import from session_allocation.py). It does nothing unless runtime.acp_backend == ACP_BACKEND_KAS. Off the loop, it asks Crew's own model selection for the starting agent, KiroCrewConfig.acp_effective_model(agent, None) (the agent's spec model, else Crew's default model): a non-empty answer is a pin, so it stops there, the same test as the chat start's configured_model. Otherwise it reads the setting for the session's folder (the runtime's folder when the session names none) and applies it with handle.set_model(model, inherit=True), so the session stays unpinned. A refusal is logged and leaves KAS's default.

Site When the model is applied Folder read
Shared sub-agent, subagent_manager/run_start.py _create_shared_session_impl after _bind_shared_handle publishes ownership, on the direct start and in _late_adopter alike, inside the sub-agent's startup clock info.cwd, else the pool folder
Workflow step, session_allocation.py open_task_session once the step holds its turn semaphore, so no other claimant runs a turn first; a cancel there gives the permit back and re-raises the step's cwd

The chat start is untouched. The acp-client.md paragraph on chat.defaultModel describes both sessions; its warm-pool shortcut stays.

Backwards compatibility

Compatible: a non-KAS runtime sends nothing new at either site; on KAS an unpinned session only gets the inherited model a KAS chat already gets, and a refusal leaves today's behaviour.
Removes nothing: no key, field, function or path is removed or narrowed; one helper is added and two call sites call it.

Tests

  • test/test_session_sharing.py::TestSharedSessionCliDefaultModel: an unpinned shared sub-agent on a KAS parent gets set_model(<setting>, inherit=True) read for its own cwd; a late-adopted one gets the same; a refused set_model still returns the provider; a kiro parent, and an agent Crew pins a model for, get no call and read nothing.
  • test/test_session_more_coverage.py::TestTaskStepCliDefaultModel: an unpinned workflow step on a KAS runtime gets the same call for its own cwd, while it holds its turn semaphore; a step with no cwd reads the runtime's folder; a kiro runtime and a Crew-pinned model get none.
  • kiro_cli_default_model is mocked everywhere; no test reads a real home.
  • Determinism: the 9 new tests are green 20 of 20 runs at -n0; both files whole are green 10 of 10 at -n 4 --dist loadgroup --max-worker-restart=2 (111 tests), and in one shuffled order (seed 22688, 111 passed).

Proof: PROVEN test/test_session_more_coverage.py::TestTaskStepCliDefaultModel::test_an_unpinned_kas_step_inherits_the_cli_default, test/test_session_more_coverage.py::TestTaskStepCliDefaultModel::test_a_step_with_no_folder_reads_the_runtimes, test/test_session_sharing.py::TestSharedSessionCliDefaultModel::test_an_unpinned_kas_sub_agent_inherits_its_folders_cli_default, test/test_session_sharing.py::TestSharedSessionCliDefaultModel::test_a_late_adopted_kas_sub_agent_inherits_it_too, test/test_session_sharing.py::TestSharedSessionCliDefaultModel::test_a_refused_cli_default_still_starts_the_sub_agent (head bc0d6407c304)

Manual verification

Reproduced and smoke-tested on Ubuntu 24.04.5 LTS (Linux x86_64, Python 3.12.3). No real KAS engine can run there, so a real AcpRuntime spawned the repo's fake ACP backend (kiro_crew.testing.fake_acp_backend) as a child process, once as the KAS relay and once as plain kiro-cli. HOME, KIROCREW_HOME and KIRO_HOME pointed into a fresh temp dir, and each folder had its own .kiro/settings/cli.json. The real SubagentManager._create_shared_session and SessionManager.open_task_session were driven, every request the runtime sent was logged, and a first turn ran on each session.

Before (base): no model frame at any site, on KAS or kiro-cli.

After:

[sub-agent / kas] model frames on the wire: [('session/set_config_option', {'configId': 'model', 'value': 'child-folder-model'})]
[sub-agent / kas] handle.inherited_model='child-folder-model' pinned _model=''
[workflow step / kas] new=True model frames on the wire: [('session/set_config_option', {'configId': 'model', 'value': 'step-folder-model'})]
[workflow step / kas no-cwd] new=True model frames on the wire: [('session/set_config_option', {'configId': 'model', 'value': 'run-folder-model'})]
[workflow step / kas crew-model=crew-default-model] new=True model frames on the wire: []
[sub-agent / ] model frames on the wire: []
[workflow step / ] new=True model frames on the wire: []

On KAS the model goes out as session/set_config_option (KAS has no session/set_model). Each session read the folder it runs in, not the parent's or the run's, stayed unpinned, and its first turn replied; a Crew default model and plain kiro-cli send nothing.

Related Issues

Closes #33744

Sibling sweep

Swept: git grep -n "create_session(" -- src/
Sibling: src/kiro_crew/subagent_manager/run_start.py:474 -- changed here
Sibling: src/kiro_crew/session_allocation.py:955 -- changed here
Sibling: src/kiro_crew/providers/acp_runtime_start.py:1076 -- not affected -- the KAS chat start already applies the setting (#34155)
Sibling: src/kiro_crew/acp/session_provider.py:418 -- not affected -- new_conversation re-applies the inherited model (#34155)
Sibling: src/kiro_crew/session_background.py:1086 -- not affected -- the background one-liner session (titles, tips) is internal housekeeping, not operator work the issue names
Sibling: src/kiro_crew/connections/mint_kas.py:290 -- not affected -- a connection-mint session that mounts one server and runs no model turn for the operator
Sibling: src/kiro_crew/connections/warm.py:1157 -- not affected -- a warm connection-verifier session, not an agent turn
Sibling: src/kiro_crew/apps/builtins/code_review_sage/sage_lib/review_pool.py:803 -- not affected -- a built-in app's own pool, outside core; not touched here
Sibling: src/kiro_crew/dashboard/handlers/session_control.py:510 -- not affected -- creates a dashboard chat slot, not an ACP session; its first turn takes the chat start above
Sibling: src/kiro_crew/dashboard/workflow_session_port.py:261 -- not affected -- the same dashboard slot create, so the same chat start

Pattern harvest

Not generalizable: a once-per-session start step is missing from two of the create paths. The shared helper is the fix for both; it is not a pattern a lint can match.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision fb57d53ede83ae0a139770dec41624f70c1cae54 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of fb57d53ede83ae0a139770dec41624f70c1cae54 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The fix has a linked issue (#33744), it closes the gap the base spec named itself ("a subagent session on a shared runtime do not read their own folder's cli.json"), and it acts at the two session-creation sites that cause the problem.

Notes

  • Item 7 — duplicate: serve_kiro_cli_default_model re-implements the read → set_model(..., inherit=True) → log-the-warning sequence that providers/acp_runtime_start.py:1279-1289 already does inline. That makes 2 copies of the sequence (I grepped kiro_cli_default_model|inherit=True), and they will drift apart. Subtraction: delete the inline block at acp_runtime_start.py:1280-1289 and call the helper there, keeping only the handle.inherited_model notice check after the call.

What this change ships

Inventory (8 items) — 7 justified

Intent: KAS sub-agents and workflow sessions run on the operator's kiro-cli default model, like KAS chats already do. FIX.

  1. A shared KAS sub-agent with no model pin starts on its own folder's chat.defaultModel — justified
  2. A late-adopted shared sub-agent gets the same model — justified
  3. Workflow planner, step and review sessions on KAS get the same model, applied while the session holds its turn semaphore — justified
  4. A step with no cwd reads the runtime's folder — justified
  5. An agent that Crew already pins a model for is left alone — justified
  6. When the model is refused, a warning is logged and no notice is shown at these sites — justified
  7. New helper module agent_sdk/kas_default_model.py — duplicate of providers/acp_runtime_start.py:1279 inline block
  8. The acp-client.md shortcut is narrowed to the warm-pool case — justified

[FIRST-PRINCIPLES-REVIEWED] fb57d53

Description read

[DESCRIPTION-READ] c89e49ce122559cf5522aacc8d9f982991443cc42ce6b45d5a91131777f7b537

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of fb57d53ede83ae0a139770dec41624f70c1cae54 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. It is a positive KAS-only check at the two create_session sites #34155 missed, and it changes nothing when the model doesn't apply.

Notes

  • A shared sub-agent only gets this when sharing finds no model pin. _sharing_plan_impl turns sharing off whenever info.model, the sub-agent role model or a routed model is set (run_start.py:125-133), so the per-role model setting can't be overridden by the inherited default.
  • This is the third start path to repeat the same check ("is the model empty or auto?" plus a cli.json read). The chat start in acp_runtime_start.py could call serve_kiro_cli_default_model too, leaving one owner. That would be a follow-up, not part of this PR.

[DESIGN-REVIEWED] fb57d53

Description read

[DESCRIPTION-READ] 74e0738200072fe560985cf558c7770744376dfc97f764c58c4cc1e69fe7c3f7

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed fb57d53ede83ae0a139770dec41624f70c1cae54 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] fb57d53

Verdict parsed from the review's SHA-scoped output markers for commit fb57d53ede83ae0a139770dec41624f70c1cae54.

False positive or not applicable? A repository writer can comment:
/ai-review override fable fb57d53ede83ae0a139770dec41624f70c1cae54 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of fb57d53ede83ae0a139770dec41624f70c1cae54 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] fb57d53

False positive or not applicable? A repository writer can comment:
/ai-review override gpt fb57d53ede83ae0a139770dec41624f70c1cae54 false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 12% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

Approved. On KAS, a shared sub-agent session and a workflow step session that nothing pins now start on the operator's kiro-cli chat.defaultModel. A single helper applies it as inherited, not pinned. Non-KAS runtimes and pinned agents send nothing new, and a refused model leaves KAS's default. The "is it pinned?" test gives the same answer as the chat start. A shared sub-agent can't carry its own model pin, because a pinned one runs in a dedicated process. The step session gets its model while holding its turn permit, and a cancellation gives the permit back correctly. Reused, reset and re-projected sessions all behave correctly. The new behaviour has tests and the spec is updated in the same commit. Nothing blocks.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit e45ae208c2 · 284 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 14:51
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 13, 2026
bolichen97 and others added 2 commits November 19, 2026 02:13
kiro-cli starts every unpinned session on its cli.json
chat.defaultModel. KAS reads no cli.json, and only the KAS chat start
applied that setting. A sub-agent sharing its parent's KAS process and
a workflow run's planner, step and review sessions are created straight
on a running runtime with no model step, so they ran on KAS's own
default instead of the operator's choice.

Add agent_sdk/kas_default_model.serve_kiro_cli_default_model and call
it at both create sites. On a KAS runtime only, when Crew pins the
starting agent no model (no spec model and no Crew default model, the
chat start's own test), it reads the setting for the folder the session
runs in off the loop and applies it as an inherited model, so the
session stays unpinned; a refusal is logged and leaves KAS's default.
The sub-agent site runs it after the bind (direct and late-adopted
starts), the step site once the session holds its turn semaphore, so
no turn runs before it. Any other runtime sends nothing.

The acp-client spec paragraph that named this gap describes both
sessions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iamwhatever
iamwhatever force-pushed the fix/33744-kas-default-model-shared-sessions branch from e45ae20 to fb57d53 Compare November 19, 2026 02:29
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 19, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Stale-PR cleanup note: rebased onto main with a one-line test-fake fix (head fb57d53); the related tests pass locally. CI on this head was cancelled by a maintainer during the repo-wide run cancellations on 2026-11-19, and we are not rerunning against that. It needs one CI rerun once runners are back to normal.

@iamwhatever

Copy link
Copy Markdown
Contributor

Stale-PR cleanup note: we reran the cancelled CI jobs on this head at 05:20Z on 2026-11-19, and @bolichen97 cancelled them again at about 05:23Z. We will not retry. When runners are ready, a maintainer can rerun the cancelled runs on this head; no code change is pending from our side.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Nov 19, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I reviewed head fb57d53. The latest push changes only a test fake (the step handle gains the kas_memory_mode attribute that open_task_session reads), and the fix itself is unchanged. Both new call sites act only when the runtime is positively identified as KAS and Crew pins no model for the starting agent. They apply the operator's own chat.defaultModel as an inherited, unpinned model, and no model id is hardcoded anywhere in the diff. The step path gives its turn permit back on any exception, and a refused model leaves the default in place. Both touched test files pass on this head, and the new positive tests fail with the source change reverted, so nothing blocks.

@bolichen97
bolichen97 merged commit b5ae653 into main Nov 19, 2026
134 of 242 checks passed
@bolichen97
bolichen97 deleted the fix/33744-kas-default-model-shared-sessions branch November 19, 2026 09:54
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 19, 2026
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.

KAS sub-agent and fresh-conversation sessions ignore kiro-cli's chat.defaultModel

3 participants