Skip to content

feat: show the prompt each turn sent in the context tab - #36795

Merged
bolichen97 merged 1 commit into
mainfrom
fix/16613-prompt-as-sent-view
Nov 20, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/16613-prompt-as-sent-view

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The side panel's Context tab shows, under the selected turn, the exact text that turn sent the agent, with secrets masked, readable only by the dashboard owner and held in memory only.

The Context tab tells you how many characters each block of a turn had, but you can't see the text itself. When a prompt goes wrong (a rule the model ignored, a block that doubled, a marker in the wrong place), the dashboard has no way to show what the agent actually read.

Why it matters

When the agent ignores a rule or a block turns up twice, the Context tab's per-block character counts say something is off but not what. Today the only way to see the text itself is to switch on the opt-in wire recorder and read its file on disk, which most people debugging a turn never do.

Not a goal

  • A new setting, Feature Preview or Developer Mode switch for this view.
  • Keeping the text on disk or across a gateway restart; the opt-in wire recorder stays the durable capture.
  • Letting app callers, or anyone but the dashboard owner, read it.
  • Changing what a prompt contains or how it is assembled.
  • Showing it anywhere but the dashboard's Context tab (no Slack, CLI or MCP surface).

What changed (motivation → approach → change)

Expanding Prompt as sent under the selected turn in the Context tab shows the text that turn sent the agent, with secrets masked. Only the dashboard owner can read it, and the gateway forgets it on restart. When there is no text to show, the tab says why in plain words. This follows the maintainer decision of 2026-11-06, recorded under docs/decisions/: no switch, owner-only, a 404 for apps, masked on read, nothing on disk.

The text kept is the one the transport received, not the one the composer built, because EssentialDelivery can swap a receipt envelope out of a member turn just before the send.

Part What it does
What is kept chat_runner.py names a prompt's turn just before the stream, and EssentialDelivery.report_next_send (essential_delivery.py) reports the text it hands send, once, after the envelope swap. Before any stream opens, every turn with a number (a prompt, a slash command, an agent-started turn) drops that turn and every later one, so a retry, a regenerate or a turn after a rewind never shows an earlier turn's text. Only a prompt keeps text. Nothing is kept for an incognito or temporary chat (by its key or the slot's own memory mode), or while the crew log is off.
Memory prompt_trace.py: the newest 8 prompts per conversation (one crew-log unit, the chat's ACP session), at most 32 conversations and 8M characters in all; the conversation written longest ago goes first, with one log line naming it and the cap, never its text. A prompt over 1M characters keeps a marker instead of its text and logs one line naming the turn. Process memory only.
The read GET /api/telemetry/prompt-as-sent?slot=&turn= (dashboard/handlers/prompt_as_sent.py) maps the tab's turn to the composer's turn number with context_turn_number in crew_log/projection_usage_measured.py (exported from crew_log/projection.py), for the chat's newest conversation only. An app caller gets the 404 an unknown route gives, plus a SEL line; anyone else who is not the owner gets 403 owner_only from require_owner_dashboard_request, the Crew log tab's check. Then 400 slot_required / 400 turn_invalid, 404 too_long, 404 not_kept. The text is masked with redact_exfiltration_urls, then redact_credentials, and the route is listed with the other redaction sinks in Settings → Security (security_posture_sinks_gateway.py).
The UI PromptAsSent.tsx, under the blocks list in ContextBreakdownPanel.tsx, is closed by default, fetches when opened and again when the turn is sent again (the query is keyed on the turn row's version), never polls, names the prompt while it loads, says in a plain line why there is no text (not_kept, too_long), shows the owner_only refusal through ErrorNotice with its sentence and the agent hand-off, and puts the text in a labelled, keyboard-scrollable region. Six strings in all 13 locales (website/src/i18n) and one API client method (api/client/telemetry.ts).
Docs The decision record and its index, the feature map, and the metrics, providers and crew-log projection specs describe the view, the store and the delivery hook.

This is the dashboard half of the issue; the durable half, outbound frames in the opt-in wire recorder, landed in #31099.

Backwards compatibility

Compatible: one new read-only route, one new disclosure and six new catalog keys; no existing route, field, setting or stored record changes.

Removes nothing: the diff only adds an in-memory store, a route, a one-shot delivery hook, a projection reader (context_turn_number), a UI row and one redaction-sink row in Settings → Security.

Tests

  • test/test_prompt_as_sent.py, over a real crew log:
    • the owner reads the selected turn with a ghp_ token masked, and the tab's ordinal joins the composer's turn number;
    • a non-owner session gets 403 owner_only; an app caller gets 404 not_found and a SEL denial;
    • an earlier conversation never shows a later one's turn with the same number;
    • the real runner keeps a persistent chat's turn and never an incognito one, even when the key-based check misses it (3 cases);
    • a prompt over the cap answers 404 too_long, counts no characters, and logs one line without its text;
    • naming a turn again drops it and every later one, keeps the total exact and keeps the chat's place in the eviction order;
    • an evicted chat logs one line naming it and MAX_SESSIONS, without its text;
    • through the real runner, a slash command forwarded to Kiro CLI at a rewound turn number leaves no earlier prompt's text.
  • test/test_essential_delivery.py::test_prompt_as_sent_is_the_text_the_wire_received: the kept text is exactly what the transport received (receipt header swapped out); another stream in between drops a pending report.
  • website/src/test/PromptAsSent.test.tsx: nothing is fetched while closed; opening shows the text; an open prompt re-reads when its turn is sent again and never shows an earlier attempt while it runs; not_kept and too_long each show their sentence; owner_only shows its sentence in an ErrorNotice alert with the agent hand-off; the loading line names the prompt.
  • test/test_security_posture.py's redactor call-site scan finds the route registered as a redaction sink.

Determinism: every added or changed backend test passed 20 times with -n0, 10 times with -n 4 --dist loadgroup --max-worker-restart=2 beside the rest of test/test_essential_delivery.py, and once with its 11 collected ids in reversed order (no random-order plugin is installed); PromptAsSent.test.tsx passed 10 times.

Manual verification

On Linux (Ubuntu 24.04, x86_64), against an isolated gateway running this patch on main at 910f01f (the rebases since then changed only context lines next to this diff), with spawn_feature_gateway("minimal", approval="yolo"), the packaged fake ACP backend, a throwaway KIROCREW_HOME, and every request to 127.0.0.1 as the dashboard owner. Every gateway was stopped by its own pid.

On main the Context tab has no such row, and GET /api/telemetry/prompt-as-sent answers 404.

With this change, one chat: turn 1 was "Please note" with a fake AWS key id (AKIA…12KL) and a fake GitHub token (ghp_ and 36 characters), then "The purple walrus audits lighthouse ledgers on Tuesdays."; turn 2 was 1,099,999 characters of ordinary words; turn 3 was "Marker alpha: the copper heron counts lanterns at midnight."

GET /api/telemetry/prompt-as-sent?slot=smoke-pas&turn=1
  -> 200 {"slot": "smoke-pas", "turn": 1, "text": "… <44,345 characters, ending in [CURRENT USER REQUEST -- respond to this]> …\nPlease note AKIA…12KL and [REDACTED: credential]. The purple walrus audits lighthouse ledgers on Tuesdays."}
GET /api/telemetry/prompt-as-sent?slot=smoke-pas&turn=2
  -> 404 {"error": "prompt was too long to keep", "code": "too_long"}
GET /api/telemetry/prompt-as-sent?slot=smoke-pas&turn=3
  -> 200 {"slot": "smoke-pas", "turn": 3, "text": "[RUNTIME] KiroCrew dashboard … <574 characters in all> … [CURRENT USER REQUEST -- respond to this]\nMarker alpha: the copper heron counts lanterns at midnight."}
GET /api/telemetry/prompt-as-sent?slot=smoke-pas&turn=0
  -> 400 {"error": "turn must be a positive integer", "code": "turn_invalid"}
GET /api/telemetry/prompt-as-sent?slot=smoke-pas&turn=abc
  -> 400 {"error": "turn must be a positive integer", "code": "turn_invalid"}
GET /api/telemetry/prompt-as-sent?turn=1
  -> 400 {"error": "slot is required", "code": "slot_required"}

The token comes back masked and the bare AWS key id as typed (abbreviated above): on this base the shared redact_credentials classes a bare access key id as an identifier, not a secret (#29423), and this route runs that chain unchanged, after redact_exfiltration_urls.

GET /api/security/posture lists the row "The prompt a turn sent" for dashboard/handlers/prompt_as_sent.py.

After GatewayHandle.restart(), turns 1 to 3 answer 404 {"code": "not_kept"}, and a fresh turn 4 answers 200 with its own text.

On disk, grep -rlF "purple walrus" over the isolated home finds only the chat transcript and the crew log (the user's own message), and no file holds the composer marker CURRENT USER REQUEST that every assembled prompt carries, so no file holds the assembled prompt.

Through the dashboard and Playwright Chromium, with the SPA built from this commit: with Prompt as sent open on turn 3 ("Marker alpha: the copper heron counts lanterns at midnight."), the turn was sent again with Edit & Resend as "Marker beta: the silver otter paints harbor maps at noon."; the disclosure stayed open (aria-expanded stayed true), and the same panel then ended in the beta line.

The app caller's 404 with its SEL denial and the non-owner 403 rest on the unit tests, because the harness mints only the owner's identity.

The harness's default backend answers slash commands locally before any stream, so the forwarded slash-command case is covered by the unit test through the real runner, not driven here.

Screenshots / video

Every picture below comes from a build of this patch (on main at 910f01f, as above), served by isolated gateways; the last one is that main's own build. The turn with the fake secrets, open in light and dark (dark set through the app's own theme setting). Its user line reads Please note AKIA…12KL and [REDACTED: credential]. The purple walrus audits lighthouse ledgers on Tuesdays.: the token is masked and the bare key id is shown as typed, as the Manual verification above explains:

Prompt as sent, open, light

Prompt as sent, open, dark

The same turn sent again with Edit & Resend while the disclosure stays open: before, then after it settles:

Prompt as sent before the turn is sent again

Prompt as sent after the turn is sent again

The 1,099,999-character turn, and a turn from before a gateway restart:

Prompt as sent, too long

Prompt as sent, not kept

Owner-only and loading (routed responses), closed by default, and main's Context tab

The harness mints only the owner's identity, so these two states come from a Playwright route on /api/telemetry/prompt-as-sent: a 403 owner_only answer, shown as an error notice in light and dark, and a request held unanswered.

Prompt as sent, owner only

Prompt as sent, owner only, dark

Prompt as sent, loading

Prompt as sent, closed

Context tab on main, no Prompt as sent row

Related Issues

Closes #16613

The issue's other half, outbound frames in the opt-in wire recorder, landed in #31099.

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

Contributed under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

No design-level concerns. It is an owner-only, in-memory, read-only addition that follows the recorded 2026-11-06 decision, it captures the text after the envelope swap, and it removes nothing.

Notes

  • prompt_trace.expect only records when the client exposes an EssentialDelivery. On a backend without one, every turn reads not_kept, which hides why there is no text; state in the spec which backends this covers.

[DESIGN-REVIEWED] 8f6d764

Description read

[DESCRIPTION-READ] 6e3d224c322baade3678860eb2600affca8d541fe73d193fcbc0b2688d001c4f

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

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 8f6d7647d04db1fe8ce685c2ed5ab1dc9a0cb5d5 — 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 to check.

What this change ships

Inventory (10 items) — 10 justified

Intent: when a turn goes wrong, let the dashboard owner read the exact text that turn sent the agent, instead of only its per-block character counts. ADDITION.

  1. The Context tab gets a "Prompt as sent" section under the selected turn. It starts collapsed and loads only when opened. — justified
  2. New read-only route GET /api/telemetry/prompt-as-sent. Only the dashboard owner can read it; anyone else gets 403 owner_only. — justified
  3. An app caller gets the same 404 as an unknown route, plus an audit (SEL) line. — justified
  4. The gateway keeps the 8 newest prompts per conversation in memory, across at most 32 conversations and 8M characters. It forgets them on restart. — justified
  5. Nothing is kept for incognito or temporary chats, or while the crew log is off. — justified
  6. A prompt over 1M characters shows a "too long" line, and the gateway logs one line that names the turn but not its text. — justified
  7. A retry, a rewind or a command at a turn number drops the text kept for that turn and every later one. — justified
  8. Settings → Security lists the new route as a place where secrets are masked. — justified
  9. Secrets and exfiltration URLs are masked when the text is read. — justified
  10. Six new strings in all 13 locales, plus a decision record under docs/decisions/. — justified

[FIRST-PRINCIPLES-REVIEWED] 8f6d764

Description read

[DESCRIPTION-READ] 889832c065e06e9cb018eef7578483af6c1119d04060d8c42527e50d026e95f2

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

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8f6d764

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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing blocks. The screenshots show every state of the new disclosure, and the blind reader correctly identified "Prompt as sent" as the main control and said they would use it.

Notes

  • prompt_masked says "with secrets masked", but in shots 01 and 02 the blind reader found a string still in full while another was replaced by "[REDACTED: credential]". They concluded the masking "goes against what the line above it promises". Change the line to say what is actually masked, e.g. "The text this turn sent the agent. Tokens and passwords are masked; key IDs stay visible."
  • prompt_owner_only says "Only the dashboard owner can read a turn's prompt." The reader asked "who 'the dashboard owner' is, or whether I am that person", and would not click "Ask the agent". Say how to get access, e.g. "Open the dashboard as its owner to read a turn's prompt."
  • The prompt_not_kept sentence chains four clauses with commas. The reader called it "hard to read". Split it, e.g. "This turn's prompt is no longer kept. Only a chat's newest turns are kept, until restart, and none for incognito or temporary chats."

[UX-REVIEWED] 8f6d764

Description read

[DESCRIPTION-READ] 11854654e0afaedc65c83f08c4773f843a4a99e2326f16c70daa2fd2d58dae6b

That sha256 names everything this verdict read: the PR description, plus the 14 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 8f6d7647d04db1fe8ce685c2ed5ab1dc9a0cb5d5 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 8f6d764

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

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

@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 18:20
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Rebased onto current main to resolve the merge conflict in docs/decisions/README.md, docs/feature-map/README.md, src/kiro_crew/dashboard/chat_runner.py and website/src/test/ApiClient.refactor.surface.test.ts. Both sides are kept in each file. The same push also carries three fixes reviewed since the last push: the new route is listed with the other redaction sinks in Settings -> Security, the open prompt is keyed on the turn row's version so a turn sent again shows its new text, and the masking test uses a checksum-valid synthetic token, which main's credential redactor now requires.

@bolichen97
bolichen97 force-pushed the fix/16613-prompt-as-sent-view branch from ad8b29c to e7664eb Compare November 17, 2026 14:56
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture_sinks_gateway.py

  • @bolichen97 posted a complete reasoning template for 8f6d764.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 17, 2026
@bolichen97

bolichen97 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Join the turn and conversation from one snapshot span=1ec550bd8fbb

Rebutted: disproportionate remedy, the same call the adjudication made (DOWNGRADE, disproportionate-remedy).
The window is the gap between the fold read and the newest-unit lookup in prompt_as_sent(): an edit-resend has to open a new unit and record the same composer turn number inside that gap.
The harm is bounded: the route is owner-only, so what shows is the same owner's own prompt from the replacement chat; nothing is written and nothing crosses users.
It corrects itself: the disclosure's query key carries the turn row's version (PromptAsSent.tsx), which changes when the turn is sent again, so an open disclosure re-reads.
Closing the gap needs unit identity in the fold state (its unit field is an ordinal counter, not a unit id): a new fold field for one read-only endpoint.
[operator: bolichen97]

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 18, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/feature-map/README.md and website/src/test/ApiClient.refactor.surface.test.ts since this head's CI ran (8826a22 -> 256d5af), and both conflicted with this branch; CI re-running. The branch now sits on current main. Main replaced the hand-kept API key list in that test with a property check, so the file takes main's version and leaves this diff; in the feature map main added a row right above the Context breakdown row this change edits, and both rows are kept. The same push carries the two fixes for the last head's reds: the prompt-as-sent handler reads the usage fold through the usage facade, which the Backend Tests facade-owner check asked for (it also cleared the Coverage Gate, which failed only because that shard did), and the owner-only refusal renders through ErrorNotice, now shown light and dark in the screenshots.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Render the owner-only rejection through ErrorNotice span=623768420dc8

fixed in d5f8d1b: the owner_only refusal renders through ErrorNotice in website/src/pages/PromptAsSent.tsx, titled with the localized owner-only sentence, the server message under it and the Ask the agent hand-off.
The plain muted line stays only for not_kept and too_long, which are states of the record, not refusals.
website/src/test/PromptAsSent.test.tsx asserts the alert role, the title, the message and the hand-off for owner_only.
[operator: bolichen97]

@bolichen97
bolichen97 force-pushed the fix/16613-prompt-as-sent-view branch from e7664eb to d5f8d1b Compare November 19, 2026 13:16
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 19, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

self-added: no

  • Capture the outbound text after prompt-block rewriting span=c3956529ef26

Rebutted: disproportionate remedy, the same call the adjudication made on this head (DOWNGRADE F1, disproportionate-remedy).
The record is the prompt text EssentialDelivery.stream hands send, after the receipt swap (essential_delivery.py:193-194); providers.md and metrics.md state exactly that.
build_prompt_blocks runs later, inside each provider's own prompt handle (session_handle_turn.py:236, client_turn.py:1667), off the loop in a thread, and only rewrites image paths and typed [image markers.
So the shown text differs only on a turn that names a picture: the path shows where the agent reads an [image: name] marker; the agent's own prompt is unchanged and nothing is stored or lost.
Reaching the post-build text means threading the one-shot report through delivery, provider and both prompt-handle paths: a new cross-module ordering contract for one owner-only debug view.
[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The reds on d5f8d1b are main's, not this change's, and each already has a fix open; this PR waits for them and then re-syncs.

Check on this head Failing test Also red on main Fix
Backend Tests (3.12, 1), Backend Tests (Windows) (4) test/test_process_cache_floor_ratchet.py::test_every_new_module_level_cache_has_a_per_test_reset (subagent_persistence.py::_NOT_DUE_MEMO) main run 44543577290, same two shards #39479 (issue #39478)
Backend Tests (3.12, 7) test/test_source_link_github_case.py::TestOneChipPerObject (assert 0 == 1) the main runs and unrelated PRs listed in #39475 #39475
Coverage Gate none of its own: it fails closed because backend-test failed follows the two above

This diff touches neither subagent_persistence.py nor the source-link code. The Sensitive Change Review still needs its reasoning template for this head.

The Context tab says how many characters each block of a turn had, but
not what the text was, so a rule the model ignored or a block that
doubled could only be chased through the opt-in wire recorder's file.

Add a "Prompt as sent" disclosure under the selected turn. The gateway
keeps the text the transport received (after the receipt-envelope swap)
for each session's newest turns, in process memory only and bounded per
session and in total; a restart forgets it and nothing is written to
disk. GET /api/telemetry/prompt-as-sent joins the tab's turn ordinal to
the composer's turn number through the usage fold and returns the text
with credentials and exfiltration URLs masked, and is listed with the
other redaction sinks in Settings -> Security. A prompt over the size
cap keeps a marker instead of its text, so the read answers 404
too_long and the tab says it was too long to keep rather than that it
was dropped.

The read is owner-only through require_owner_dashboard_request, as the
Crew log is; an app caller gets a 404 and a SEL line. Restricted
(incognito, temporary) sessions are never kept. No new switch, per the
maintainer decision recorded under docs/decisions/.
@bolichen97
bolichen97 force-pushed the fix/16613-prompt-as-sent-view branch from d5f8d1b to 8f6d764 Compare November 19, 2026 23:40
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in test/conftest.py and test/conftest_resets.py (#39479, the per-test reset behind the module-cache ratchet red on Backend Tests (3.12, 1) and Backend Tests (Windows) (4)) since d5f8d1b was tested (256d5af -> 3688176); CI re-running. The patch is unchanged. The Backend Tests (3.12, 7) red in test_source_link_github_case is also main's, and its fix (#39475) is still open.

[operator: bolichen97]

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 8f6d764
  • What rule changed: no gate, matcher, sandbox, approval or redaction rule changed. The one sensitive file, src/kiro_crew/security_posture_sinks_gateway.py, gains one row in _GATEWAY_SINKS, the list the Security posture page shows under "Output redaction": "The prompt a turn sent", naming dashboard/handlers/prompt_as_sent.py. That row describes a new read this commit adds; it enforces nothing. The read, GET /api/telemetry/prompt-as-sent?slot=&turn=, returns the text one dashboard turn sent the agent from an in-memory record (kept only while the crew log is on: newest 8 turns per session, 32 sessions, no prompt text written to disk, none kept for an incognito, temporary or other restricted session). An app caller gets a JSON 404 not_found, as context-trace gives one, plus a SEL line; any other caller that is not the dashboard owner gets a 403 owner_only (a stale pre-owner session gets a 401); and the text passes redact_exfiltration_urls and redact_credentials before it is returned.
  • Before -> after (what was allowed/blocked, now): nothing that was allowed is now blocked, and nothing that was blocked is now allowed. Before, the posture list had no row for this read because the read did not exist (the route answered 404). After, the owner can read a recent turn's prompt text, masked, and the posture list names that egress next to the other output-redaction sinks.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a wrong posture row would only mis-describe a sink; it cannot break a command, lock anyone out or change what is masked. For the read itself, the worst case is a secret the credential redactor does not recognise reaching the owner's own browser in the owner's own prompt text (an AWS access key ID, for one, is returned as is). The text is the owner's conversation and memory, which the owner can already read elsewhere, and no other caller gets it.
  • Evidence checked (which sandbox result proves it): on a disposable Ubuntu 24.04 host, a gateway built from this exact tree (393ede25b55d) ran with an isolated home and the packaged fake ACP backend, the redaction setting left at its default (off; this read masks either way). /api/security/posture listed the new row with the text above. One chat: turn 1 answered 200 and its text showed a ghp_ token as [REDACTED: credential] and an AKIA key ID unmasked; a turn over the size cap answered 404 too_long; turn=0 and turn=abc answered 400 turn_invalid; no slot answered 400 slot_required. After a gateway restart every earlier turn answered 404 not_kept. A search of the whole isolated home found the user's message only in the session and crew-log files it was already written to, and the assembled prompt in no file, before and after the restart. On a clean-base build the same request answered 404 Not Found.
  • No regression:
    • Tools still work (which tools/commands were run, result): in that host run every turn of the chat was answered, Edit & Resend replaced the shown prompt with the resent one, and the turn after the restart was answered and readable. Before the stream the runner drops this turn's older records and registers a report, and the delivery calls that report, just before the send, with the text it was already sending; none of this changes the text sent.
    • Backward compatible (old config / old data / old callers still work, how checked): no config key, stored file or existing route changed. The posture endpoint returns one more row in an existing list, which its existing tests read. The new route is additive, and no prompt text persists (the eviction and too-long log lines carry only a session id, the cap it went over and, for a too-long prompt, its turn number), so there is no stored data to migrate.
    • Existing tests (which suites passed on this head): on the same tree, the host ran all 66 gates of the repository profile: 64 passed; test:electron passed on a re-run after npm ci; the backend scoped-tests gate exited 1 in a run made before the base-red tests were deselected, its failing test ids were not captured, and its batch 1/8 passed on re-run. The local gate, which runs the same 4369 targets, then passed backend 1/8 18296, 2/8 29923, 3/8 28189, 4/8 27662, 5/8 32866, 6/8 31052, 7/8 25800 and 8/8 1106 tests, and frontend 12089 and 10716 tests (it stopped after shard 6/8, so 7/8, 8/8 and the frontend run came from its own plan). Shard 6/8 also had one failure, in a push-guard signal-timing test this commit does not touch, which then passed 5 of 5 times alone on this tree and on the base. Three tests already red on the base were deselected. In CI on this head, 84 check runs passed, among them Backend Tests (3.12) shards 1-8, Backend Tests (Windows) shards 1-8, the IPv6 (ubuntu-latest and windows-latest), namespace sandbox, crew container and Kernel Lock Owner backend lanes, Windows Fail-Closed Sandbox Contract, Native Redaction Gate, Real Adapter Contract Tests, New-test stability (ubuntu-latest and windows-latest), Frontend Tests 1-4, both Electron Shell Tests jobs, the four E2E lanes (stub ACP backend, private member namespace, gateway boot on ubuntu-latest and windows-latest), Integration (in-process gateway), both lint and type-check jobs and Coverage Gate; when this was written the only failing check on this head was this Sensitive Change Review.
  • How to undo: revert the single commit 8f6d764. The route, the posture row and the in-memory record go away. No config or data migration is needed.

[operator: bolichen97]

@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 20, 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.

Reviewed head 8f6d764 by tracing the capture path from the dashboard runner into the provider's delivery hook. The hook fires once, only for the prompt object the runner registered, after the receipt swap, so slash commands and internal streams are never recorded. The read route refuses app callers with an indistinguishable 404 and an audit line, refuses anyone who is not the dashboard owner, skips restricted sessions, and masks secrets on the way out. The in-memory store keeps its character total exact through rewinds, oversize prompts and eviction. The turn-number join will not show one conversation's text under another's turn. The new and touched backend tests pass locally on this head, and CI is green, so nothing here blocks.

@bolichen97
bolichen97 merged commit 29cc563 into main Nov 20, 2026
99 of 100 checks passed
@bolichen97
bolichen97 deleted the fix/16613-prompt-as-sent-view branch November 20, 2026 01:20
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 20, 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.

Show the exact prompt text each turn sent to the agent (Context tab, Developer Mode)

2 participants