Repository navigation
harness-sdk: a fenced harness exits even while a task holds an event sender - #1826
Merged
Merged
Conversation
…sender A harness whose attach was superseded, and that saw no newer token in its grace period, never exited. Its "fenced exit" dropped the command channel and drained the event channel until every sender was gone, but a task other than the engine still held a sender (the per-connection hook and MCP socket tasks clone it, and aborting their listener does not stop a connection in flight). The drain waited forever, the process ignored reconnect nudges, and agentd kept reattaching to it instead of starting a fresh harness, so the session took no prompts until someone killed it. All three exits (token unavailable, fenced, end of transport) now go through `close_out`: drop the command sender, close the event receiver before draining it, and wait at most ENGINE_EXIT_GRACE (10 s) for the engine, aborting it after that. Two tests hold a stray sender, one with an engine that never finishes; both hang on the old code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A session stopped taking prompts after a burst of prompts broke its harness connection.
Superseded: it had already moved to a newer attach epoch.SUPERSEDED_TOKEN_GRACE, so the harness took its "fenced exit". That exit is designed to end the process, so that agentd starts a fresh harness on the host's next attach.prompt_undeliverableuntil the harness process was killed by hand.Fix: all three transport exits use
close_out:ENGINE_EXIT_GRACE(10 s) for the engine, then abort it.The start-up error path already closed the receiver; the fenced and normal exits did not.
Test plan
engram-harness-sdk/tests/attach_token.rshold a stray event sender: one with an engine that finishes, one with an engine that never finishes. On the old code both hang until the test timeout. With the fix they exit at the expected grace periods.cargo nextest -p engram-harness-sdk(46) and-p engram-harness-noop.cargo clippy -D warningson macOS, and foraarch64-unknown-linux-musl(sdk, harness-claude, harness-noop);cargo fmt.🤖 Generated with Claude Code