Skip to content

fix(ahp): restore stdio inheritance and emit turn lifecycle - #272

Merged
danielkov merged 6 commits into
mainfrom
fix/ahp-herdr-lifecycle
Oct 14, 2026
Merged

danielkov merged 6 commits into
mainfrom
fix/ahp-herdr-lifecycle

Conversation

@danielkov

@danielkov danielkov commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Restore full host-environment inheritance for AHP stdio hooks and emit observe-only turn.start and turn.end events from Kit's native agent-loop boundaries.

Motivation

The AHP SDK 0.7 upgrade changed the default subprocess environment, stripping the variables HerdR requires and silently disabling its reporting. HerdR's lifecycle subscriptions also require turn events that Kit previously did not grant or emit.

Impact

Stdio hooks receive Kit's full environment, including credentials; only trusted hooks should be configured. Explicit transport env entries continue to override inherited values.

Technical details

Turn observations preserve native session and turn IDs across CLI, A2A, and ACP runs. Tools and model continuations remain inside the same logical turn. The loop observer queues turn boundaries per session; the session delivers them in order before its next prompt, model, or session-end hook, and whenever it goes idle (ACP actor iteration, CLI wait on background tasks). No background worker; abrupt process exit remains best effort. Cancelling a CLI prompt now retires the interrupted turn, which also records cancellation results for unanswered tool calls.

mise run test and test:headless now run with an empty temporary HOME, so tests no longer load the developer's global ~/.agents hooks and skills.

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

One cancellation-path issue leaves logical turn lifecycle events unbalanced.

Comment thread src/runtime.rs
kit-code-agent[bot]
kit-code-agent Bot previously approved these changes Oct 13, 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.

No issues found. The changes look good to merge.

Replace the background delivery worker with per-session queues that the
session drains at its next hook point and whenever it goes idle.

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

Two turn-observation delivery regressions need attention: cancellation can discard an in-flight terminal observation, and ACP v1 does not flush terminal observations when its session becomes idle.

Comment thread src/ahp/turn.rs Outdated
Comment thread src/ahp/turn.rs
…P v1

Run each session's drain in a spawned task serialized by a per-session
lock, so a dropped caller cannot discard an observation mid-delivery.
Drain after every ACP v1 actor iteration so turn.end is not held while
the session is idle.
kit-code-agent[bot]
kit-code-agent Bot previously approved these changes Oct 14, 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.

No issues found. The changes look good to merge.

Tests built Runtime from the real ~/.agents, so a developer's global hooks
and skills ran during tests.

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

@danielkov
danielkov merged commit 0882cf0 into main Oct 14, 2026
6 checks passed
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.

1 participant