Skip to content

fix: send admitted prompts at the AHP turn-start boundary - #344

Merged
danielkov merged 4 commits into
mainfrom
danielkov/fix-ahp-turn-start-prompts
Nov 6, 2026
Merged

danielkov merged 4 commits into
mainfrom
danielkov/fix-ahp-turn-start-prompts

Conversation

@danielkov

Copy link
Copy Markdown
Contributor

Summary

Deliver the effective admitted prompt and attachments on AHP turn.start, with truthful user/external trigger provenance and enforceable denial, prompt replacement, and message effects.

Motivation

AHP defines expanded prompt content at the turn-start boundary. Kit previously reported an empty, externally triggered turn start and exposed the prompt only through user.message.inbound, masking interoperability gaps in backends that relied on that event alone.

Technical details

Keep user.message.inbound as a distinct input-arrival boundary and apply its effects before turn-start admission. Preserve logical message identity across both events so receivers can correlate transcript persistence without suppressing either policy decision. Mid-turn arrivals emit inbound without creating another turn start; internal notification turns do not invent an inbound message.

Apply full canonical prompt-list replacements within the admitted item scope, preserving authorized opaque attachment identities and persisting the effective input. Advertise only supported turn-start effects, and preserve cancellation and turn/session lifecycle ordering.

@danielkov danielkov added the bug Something isn't working label Nov 6, 2026

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Turn-start handling can leave denied input pending, discard ACP replay identity, and emit unmatched completion events; the documented authority table also needs updating.

Took 24 min

Comment thread src/ahp/prompt.rs Resolved
Comment thread src/ahp/prompt.rs Resolved
Comment thread src/ahp/prompt.rs Resolved
Comment thread src/ahp.rs Resolved
@danielkov
danielkov marked this pull request as ready for review November 6, 2026 21:54

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Include prepended notifications in the admitted turn scope — Notifications submitted with a user prompt are omitted from turn.start.items and survive full replacement or denial, allowing a model call after denial.

[P2] Preserve ACP replay identity when replacing admitted input — A legal replacement with a new canonical message ID drops the host-owned ACP message identity, invalidating the live replay cursor and changing the identity returned by full replay.

[P3] Pair turn completion when inbound interception is cancelled — Interrupting during user.message.inbound skips turn.start but still delivers the native cancelled turn.end, leaving receivers with an unmatched completion.

[P3] Update the documented turn-start authority — The hook-authority table still describes turn.start as observe-only although Kit now grants denial, prompt replacement, and user-facing messages.

Took 8 min 57 sec

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Admission can falsely acknowledge model-switch compaction, redispatch historical input after denial, and omit the start event for a background-approval turn.

Took 16 min

Comment thread src/runtime.rs Resolved
Comment thread src/ahp/prompt.rs Resolved
Comment thread src/ahp/prompt.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A cancellation before turn-start delivery can leave an unmatched turn.end because the new start claim suppresses the completion fallback.

Took 12 min

Comment thread src/ahp/prompt.rs Resolved

@kit-code-agent kit-code-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found. The changes look good to merge.

Took 11 min

@danielkov
danielkov merged commit 18b0310 into main Nov 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant