Repository navigation
Conversation
|
Intent: On kiro-cli and KAS, a custom agent's persona reaches the model once: Crew drops its own copy only when it can show that copy is identical to the one the harness already delivered. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
2 similar comments
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Every item traces back to the doubled persona tracked in #13305, which the description says was reproduced on main. The extra machinery decides when the block can be withheld without the persona going missing. What this change shipsInventory (8 items) — 7 justifiedIntent: on kiro-cli and KAS, a custom agent's persona reaches the model once instead of twice. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] a5defa3 Description read[DESCRIPTION-READ] 13af22b45d83a75dbabd34299b9a3ed796b5b1933e49c6ad836ba325d85dd704 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the persona block is only withheld when a recorded snapshot proves the harness holds the same text, and every case it can't prove still sends the block, so the worst outcome is a duplicate. Notes
[DESIGN-REVIEWED] a5defa3 Description read[DESCRIPTION-READ] 81d6fed544b4f3abcbb7b19f0b7fa14123b8b0075ff1dd5c9adf5152db7b6a8f 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 |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
c9a073d to
47b3907
Compare
|
|
|
|
Note on the |
|
Reviewed, not approving (crew-pr-reviewer). This is a large change (+1126) to how a custom agent's prompt is sent on kiro-cli and KAS. It needs a maintainer's review. |
cruisercohen
left a comment
There was a problem hiding this comment.
Delta review at head 21ecbc4 (rebased since my last review at 1d50497). The earlier blocker is addressed: native_spec_prompt_shape now rejects an absolute file:// persona whenever sandbox_may_hide_path says a sandbox tier on this host can mask it, and that check fails closed (an unreadable host reports the path hidden), so the block is kept rather than lost. The targeted context, persona-snapshot, essential-delivery, member-context and sandbox-plan suites pass locally on this head (801 passed). One blocker remains:
test/test_context.py:2055adds a newpytest.skip("symlinks unavailable on this host")in thesandbox-masked-linkcase, which the GPT review lane blocks under the repo's rule that a ratchet may only tighten. On a host without symlink privilege, the masked-link assertions would silently not run. Please make the link case run everywhere, or split it into a separately gated test so the existing file gains no skip. Note that themake_dir_linkhelper the lane suggests is not intest/conftest.pyon this head.
Also, since this head now changes the sandbox module (sandbox.py), the Sensitive Change Review lane needs a maintainer's sign-off on top of review approval.
21ecbc4 to
5f30d35
Compare
|
@cruisercohen thanks for the delta review. On The skip is gone. The The rebase picked up Still open, both maintainer calls:
@iamwhatever the Design Watch item you held on (a |
|
5f30d35 to
a2892eb
Compare
cruisercohen
left a comment
There was a problem hiding this comment.
Re-reviewed at dac76b6. My remaining point from the review on 21ecbc4 is addressed: the sandbox-masked-link case in test/test_context.py now builds its link with make_dir_link, which test/conftest.py re-exports on this head, so the case runs on every host and the file gains no skip. My change request is resolved on the code.
I am not approving, because this still needs the following:
- Merge conflict with main: the branch needs a rebase.
Backend Tests (3.12, 2)andmacOS Tests (2)fail intest_provider_spawn_off_loop_18172.py::test_cancellation_during_the_spawn_still_reaps. That test was fixed on main after this run (#19358), so a rebase should clear it, andCoverage Gate(failing closed on that lane) with it.Sensitive Change Reviewis red because the head changessandbox.pyfrom a fork. The newsandbox_may_hide_pathonly reads paths and fails closed, but that gate and the post-compaction version floor both need a maintainer's sign-off.
|
@cruisercohen thanks. Rebased onto current |
|
This PR stops a custom agent's persona reaching the model twice on kiro-cli and KAS. Crew withholds its [AGENT SYSTEM PROMPT] block only when a snapshot shows the harness loaded the same text: read right before spawn and before each session/set_mode, from the skill-view alias when one exists, and recorded by one writer on create and resume. I re-read the production diff at 2790a90. The blocker from our earlier hold is fixed: native_spec_prompt_shape now refuses any absolute file:// target that sandbox_may_hide_path says any tier's masks may hide. That check compares both the given and resolved spellings against every tier's trees, and it fails closed to "hidden" on any error, so a file the sandboxed harness cannot read keeps the block instead of leaving no persona. I tried edited-after-spawn specs, checkout-shadowed names, relative, ~ and managed prompts, placeholders, and KAS file:// payloads. Each mismatch keeps the block, and I found no path that drops the persona. I am holding on hard blockers, not a defect. First, the branch is now CONFLICTING/DIRTY against main and needs another rebase. Second, Sensitive Change Review is red because a fork PR changes sandbox.py, which that gate refuses outright, so a maintainer has to take the change over on an in-repo branch (as the author offered) or sign it off. Third, the maintainer also needs to answer the question still open from cruisercohen's first review: do you accept the static kiro-cli >= 2.28.0 floor for withholding the persona after a compaction, or do you want a verified-version list? — crew-pr-reviewer (deep re-check) |
|
@cruisercohen thanks for approving the runs. Two reds on
Everything else is green, and the GPT, Opus and First Principles lanes report no blocking findings; the Sensitive Change Review still needs a maintainer, as noted above. |
|
@cruisercohen @iamwhatever rebased onto
The persona logic is otherwise the same as |
cruisercohen
left a comment
There was a problem hiding this comment.
Re-review at 8dd4a97923, answering your note on the sandbox side of the rebase.
The resolution checks out. sandbox_may_hide_path is byte-for-byte the function we reviewed. The two names it reads now live in owner modules, and the facade serves them only as attributes of the module object, which a global lookup inside sandbox.py never goes through, so the explicit imports are required. I checked that locally: with those two imports removed, test_sandbox_may_hide_path_leaves_readable_trees_visible and test_sandbox_may_hide_path_changes_nothing_and_asks_no_ssh fail (every path reports hidden). With them in place, the sandbox_may_hide_path tests and all of test_sandbox_refactor_facade.py pass. Keeping the function next to wrapped_by_crew_sandbox reads fine to me. Whether it should move to an owner module is a maintainer's call.
The other changes are re-homes too. The bracket AST assertion moved with its test into test_worker_agent_load_bracket.py, and native_spec_prompt_across_compaction gets its row in the frozen AcpProvider member inventory. The persona logic is unchanged.
The red Backend Tests (3.12, 5), (Windows) (5) and (macOS) (1) all fail only in test_acp_bindings.py, on approval_withdrawable and the new approve_tool signature. That comes from the main commit this branch sits on, which predates #20902. A rebase onto current main should clear those and Coverage Gate. Sensitive Change Review still needs a maintainer, because this touches the sandbox.
|
@cruisercohen @iamwhatever rebased onto What moved:
Also new since
The Design lane suggests it read the planner's mask output instead of keeping its own list of masked trees. I've kept the list. Reading the planner's output means building plans, and a plan answers a narrower question: The two lists cannot drift apart unnoticed. Two things on this head are maintainer calls:
One red on this head is a timeout rather than a failure: Backend Tests (3.12, 2) stopped |
|
@cruisercohen @iamwhatever rebased onto
One correction to my last note: Checked before the push. On this commit, all 48 gate commands I ran exit 0, among them Fast Gate's new flake-pattern ratchet against the merge-base, and 15,993 tests pass in 294 test files: this PR's own, every test that imports or names one of the five modules |
|
Hi Matt, PR #17172 (send a custom agent's prompt once on kiro-cli and KAS) is rebased onto current main to clear the conflicts with #23139 and #23010, and it needs your approval: #17172 On the new head, e111245:
What still needs a maintainer:
Thanks! |
kiro-cli reads a custom agent spec's prompt when it activates the agent, and KAS receives it on session/new. Crew also injected the same text as its AGENT SYSTEM PROMPT block, so on those two harnesses a custom persona reached the model twice: at session start, and again after every compaction. The runtime records the harness's copy of the prompt only for the backends in ACP_BACKENDS_NATIVE_SPEC_PROMPT (kiro-cli, KAS); that recorded copy is the whole report, and the prompt builder withholds its block only when one exists and the text it would send is word for word that copy: a user-level spec's inline prompt or absolute file:// prompt that Crew's placeholder pass leaves unchanged. The managed default prompt, relative and home-relative (~) file:// paths, project-level specs and every other harness keep the block. So does a file:// target that a Kiro Crew sandbox on the host may hide (sandbox_may_hide_path: every tier's masked trees, files and ~/.ssh, links resolved): Crew reads the file from the gateway, outside the sandbox, while a sandboxed harness may be denied it and drop it silently. The harness's copy is recorded at the moments kiro-cli reads the spec, from the spec kiro-cli is given -- its skill-view alias when a view was prepared, a copy taken at preparation, else the plain name as kiro-cli resolves it from the process cwd (a checkout spec declaring the name records nothing, so the block is sent; otherwise the user-level spec) -- read once, immediately before the request: the runtime reads the translated --agent spec before its process spawns, and the session/set_mode bracket reads the alias it sends and returns the pair. An edit landing after that read leaves the file different from the snapshot, so the block is sent, never withheld. A plain session/new reads nothing, so the file as it reads at session start is never the source: a persona edited between the spawn and the session keeps its block, because kiro-cli does not hold the edited text. One recorder writes the session's document map, after the bracket and after every merge, so a member launch whose sources already carry the persona gets no second record of the same text. A KAS host is recorded from its wire payload. Reinjection after a compaction withholds the block only on a harness shown to keep the spec prompt through its own compaction, ACP_BACKENDS_NATIVE_SPEC_PROMPT_ACROSS_COMPACTION, reported by the providers as native_spec_prompt_across_compaction, and only from the kiro-cli release that transcript was taken on, NATIVE_SPEC_PROMPT_ACROSS_COMPACTION_MIN_KIRO_CLI_VERSION (2.28.0), read off the agentInfo.version the process reported at initialize. A floor, not a list of releases: below it, and when no version was reported, the block is sent, a duplicate of a prompt the harness may still hold, which costs tokens and nothing else. KAS is not in the set, so a KAS session is sent the block once after a compaction even when the recorded copy still matches. Session start is unchanged on both. Closes kirodotdev#13305
|
Holding a5defa3 for a maintainer; I found no defect. The persona block is withheld only when a snapshot proves kiro-cli or KAS loaded the same text, and every unproven case still sends it. What still blocks:
The cases left doubled are tracked in #13305. — crew-pr-reviewer (r128) |
|
[operator: bolichen97] Continuing this in #31875; thanks for the start. |
Problem / Motivation
Goal: On kiro-cli and KAS, a custom agent's persona reaches the model once instead of twice.
Every custom agent that runs on kiro-cli or KAS gets its persona twice. The harness loads the spec's
promptitself, and Crew adds the same text again as itsAGENT SYSTEM PROMPTblock, at session start and after every compaction. That covers app agents (afile://prompt), user and third-party specs with an inlineprompt, and Crew's own conductor and worker agents. A regression test reproduced it onmainat c6bfd72 for both an inline prompt and an app'sfile://prompt.Why it matters
An affected session carries a second copy of its persona in context for the rest of its life, and every sub-agent a kiro-cli conductor spawns starts with its worker instructions twice: context space and input tokens spent on every turn for nothing. #13257 removed the same doubling for Crew's default prompt; custom agents still have it.
Not a goal
{bot_name},{{MAX_SUBAGENTS}}). The harness copy is unfilled, so both copies stay and the one Crew fills keeps the persona correct.What changed (motivation → approach → change)
Crew drops its copy of a custom persona only when a snapshot proves the harness loaded exactly that text; every other case gets the block.
agent_sdk/backends_mcp.py(re-exported byagent_sdk/backends.py),acp_backends.pyACP_BACKENDS_NATIVE_SPEC_PROMPT(kiro-cli, KAS: they deliver a spec's ownprompt);ACP_BACKENDS_NATIVE_SPEC_PROMPT_ACROSS_COMPACTION(kiro-cli alone) and its release floorNATIVE_SPEC_PROMPT_ACROSS_COMPACTION_MIN_KIRO_CLI_VERSION= 2.28.0 (a floor, not a list)providers/base.py,agent_sdk/context.pynative_spec_prompt_across_compaction, True for kiro-cli at or above the floor (read offagentInfo.version), False otherwise (block sent, a duplicate at worst); a recorded copy is itself the report of native deliverymember_essential_context.pyfile://no sandbox may hide), the keytemplate://<agent>#prompt, andnative_spec_prompt_copy(agent, transport=, work_dir=): reads the spec kiro-cli is given: its skill-view alias when one was prepared (a copy, so a later source edit leaves the snapshot on what kiro-cli runs), else the plain name as kiro-cli resolves it (a same-named checkout spec records nothing)acp/runtime_mode_activation.py(bound onacp/runtime_class.py),acp/runtime_spawn_launch.py,acp/runtime_session_create.py,acp/runtime_session_load.py--agentspec before the launch, the idsession/set_modenames before each attempt (an app's launch copy is not a skill-view alias, so a session it runs records nothing and keeps the block);_record_native_persona_snapshotis the map's one writer onsession/newandsession/load; a KAS host records only its wire payload's promptsandbox_argv.pysandbox_may_hide_path, read through thesandbox.pyfacade: may any tier's masks (links resolved) deny a child the path; reads only, errs toward hiddencontext_assembly/agent_spec.py(bound onkiro_crew/context.py),context_assembly/turn_message.py,context_assembly/turn.pycontext-management.md, two system-spec modules,agent-spec-fields.mdkiro-cli reads a spec at spawn and
session/set_modeonly, never at a plainsession/new, so the copy is read right before those two reads; an edit landing after that read leaves the file different from the snapshot, so the block is sent. KAS stays out of the compaction set: nothing says its summarization keeps the spec prompt. A wrong guess drops the persona instead of repeating it, so every unproven case sends.Backwards compatibility
Compatible: nothing main accepts is rejected, renamed or removed. A loaded copy is recorded only on kiro-cli and KAS, so a provider without one keeps the block, as does a turn with no provider. The block is withheld in proven sessions and the handle's document map gains one key; readers:
acp/kas_agents.py:resolve_prompt-- KAS still gets the prompt onsession/new; test_custom_persona_reaches_real_native_harness_oncecontext_assembly/turn_message.py:build_message(ContextBuilder.build_message) -- sub-agent and cron turns build through it; itsnative_documentshand-off to member essentials blanks a body the harness holds, prompt key included (test_native_envelope_blanks_the_persona_recorded_under_the_prompt_key)context_assembly/turn.py:post_compaction_parts-- same rule after a compaction, default prompt restored; test_post_compaction_reinjection_applies_the_same_rulecontext_blocks.py:split_blocks-- sizes the blocks a prompt carriesacp/session_handle.py:native_context_documents-- the key sits beside a member launch's template resources; the owner persona travels once; test_owner_persona_is_untouched_by_the_native_spec_prompt_ruleTests
test_context_agent_prompt.py(TestLoadAgentPrompt, moved whole fromtest_context.pyso both stay under the 2,000-line cap): once on kiro-cli and KAS; the block kept for ten unprovable shapes (two sandbox-masked) and an edited spec; the alias read (an edited source sends the edited persona once) and a checkout-shadowed name; after a compaction kiro-cli withholds at the floor, KAS and a kiro-cli below it send once.test_acp_persona_snapshot_moments.py: the recorder stores the spawn copy, not the file at session start; the bracket reads the alias it sends and never writes the map; the spawn read precedes the launch; the recorder prefers theset_modepair; an app's launch copy records nothing at spawn or atset_mode.test_acp_spawn_offload.py: a member's persona is recorded once on create and resume; four bracket tests unpack its(alias, persona)return.test_context_widget_block.py: a conductor whose spec prompt kiro-cli holds gets a block of only the widget pointer on the dashboard and no block elsewhere; a conductor spec edited after activation keeps its whole block.test_essential_delivery.py(realsession/newandsession/load; create-then-resume on one transport: one record each, withheld next turn; after a compaction withheld at 2.28.0, sent once at 2.27.1),test_member_essential_context.py(the native envelope),test_native_spec_prompt.py(both sets, the floor table, both providers at, below and without a version),test_agent_spec_hardened_reads.py(the hardened reader),test_sandbox_plan.py(the predicate covers every tree each plan masks),test_runtime_bindings.py(the persona methods in the runtime's member inventory).Manual verification
Real kiro-cli 2.28.0 running this branch. Positive case (user-level spec, token-free absolute
file://persona): one native document atsession/new, 0 blocks at start, on resume and after a forced compaction, the same role answer throughout. Negative case (a persona with Crew's placeholders): no snapshot, block kept. Transcript and driver. Not proven live: afile://~/prompt (host policy blocks that write) and a sandbox-masked one; tests keep the block for both.A security scan of the changed files: no Critical findings, and no Semgrep, secret or CVE findings.
Related Issues
Follows #13257 (the same doubling for Crew's default prompt).
Part of #13305, which stays open for the three cases this PR leaves doubled: personas that use Crew's placeholders, a capability-materialized owned member whose spec still carries the managed
file://pointer, and an app agent kiro-cli runs from a launch copy (#21867).Pattern harvest
Rule candidate: review-prompt
Pattern: a block Crew injects must first ask the live provider whether the harness already delivers it and compare against the copy the harness loaded, read from the spec it is given, not the file at turn time
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)