Skip to content

feat: add ACP session runtime and transcripts - #30835

Merged
hugodutka merged 1 commit into
hugodutka/acp-fix-anyof-validationfrom
hugodutka/acp-session-runtime
Oct 26, 2026
Merged

hugodutka merged 1 commit into
hugodutka/acp-fix-anyof-validationfrom
hugodutka/acp-session-runtime

Conversation

@hugodutka

@hugodutka hugodutka commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Create and run agent-local ACP sessions with configurable harnesses, prompt submission, interruption, and ordered transcripts. Track session status and failures, scope permission grants to running turns, and stop session processes when the manager shuts down.

Tests are in the next PR in the stack.

Depends on #31128.

Generated with Codex, carefully reviewed by Hugo.

@hugodutka
hugodutka added this pull request to stack #30836 October 15, 2026 11:06
@hugodutka
hugodutka removed this pull request from stack #30836 October 15, 2026 13:08
@hugodutka
hugodutka added this pull request to stack #30843 October 15, 2026 13:08
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch from 184e24c to 0c2622c Compare October 15, 2026 15:48
@hugodutka
hugodutka removed this pull request from stack #30843 October 15, 2026 15:50
@hugodutka
hugodutka added this pull request to stack #30859 October 15, 2026 16:13
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch from 0c2622c to 7f87146 Compare October 15, 2026 17:31
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch from 7f87146 to 91eda3a Compare October 16, 2026 15:19
@hugodutka
hugodutka removed this pull request from stack #30859 October 16, 2026 15:20
@hugodutka
hugodutka added this pull request to stack #30904 October 16, 2026 15:21
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch 3 times, most recently from 998ba37 to 96d1b2e Compare October 19, 2026 12:58
@hugodutka
hugodutka removed this pull request from stack #30904 October 19, 2026 14:05
@hugodutka
hugodutka added this pull request to stack #31024 October 19, 2026 14:05
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch 2 times, most recently from 7f5886e to e2dc8a6 Compare October 20, 2026 15:58
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch 2 times, most recently from 7fdd5d7 to c9df05b Compare October 20, 2026 17:51
@hugodutka
hugodutka removed this pull request from stack #31024 October 20, 2026 17:52
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch 5 times, most recently from 4eb4426 to 5a06a9d Compare October 20, 2026 19:01
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch 5 times, most recently from d062169 to 6ca2e11 Compare October 21, 2026 13:36
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch from 6ca2e11 to 16838d9 Compare October 21, 2026 13:49
Base automatically changed from hugodutka/acp-subagents-discovery to main October 21, 2026 14:18
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch 2 times, most recently from 4c592d3 to 35d1c89 Compare October 21, 2026 14:21
@hugodutka
hugodutka changed the base branch from main to hugodutka/acp-fix-anyof-validation October 21, 2026 14:22
@hugodutka
hugodutka added this pull request to stack #31131 October 21, 2026 16:34
@hugodutka
hugodutka marked this pull request as ready for review October 21, 2026 16:34
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch from 35d1c89 to 881d061 Compare October 21, 2026 16:56
@mafredri
mafredri self-requested a review October 22, 2026 09:44
Comment thread agent/x/agentacp/session_init.go Outdated
HarnessDisplayName: cfg.displayName,
Status: workspacesdk.ACPSessionStatusInitializing,
Cursor: workspacesdk.ACPCursor{
Epoch: uuid.New(),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this official ACP spec? Feels weird to have an epoch with UUID.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No, this is for our own use. We need ids for turns that are unique even across workspace agent restarts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about GenerationID instead of Epoch? I feel like epoch carries the wrong connotation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll do that

Comment thread agent/x/agentacp/session_init.go Resolved
Comment thread agent/x/agentacp/session_init.go Resolved
Comment thread agent/x/agentacp/manager.go Resolved
Comment thread agent/x/agentacp/session.go Resolved
}

func (s *SessionFSM) updateStatusLocked(operation sessionOperation) error {
target, ok := sessionTransitions[s.info.Status][operation]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we enter error state (s.info.Status), the map above has no recovery path. So any consecutive Message would return !ok here? Oversight or intentional? Don't harnesses produce recoverable error states too? I don't know what classifies, but e.g. "over limit" or "model overloaded" are both recoverable states. Don't know if they'd produce error though.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Intentional. A later PR introduces recovery.

Comment thread agent/x/agentacp/session.go Resolved
Comment thread agent/x/agentacp/session.go Resolved
// replaces permissionCtx, allowing an interrupted turn's request. The SDK
// dispatches callbacks asynchronously without turn identity, so capturing the
// context before locking cannot reliably bind it to the original turn.
// We'd need a change in the SDK to resolve this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds like this TODO shouldn't be deferred?

@hugodutka hugodutka Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't think deferring this is a problem. We approve all requests automatically. The ACP spec says that if a turn gets interrupted then we must send a "cancelled" response instead of "approved" for the requests sent during that turn. So the problem here is that we now have a small race condition: if you interrupt a turn, then right away start a new turn, and then get a late permission request, we'll send "approved" instead of "cancelled". I don't know what the consequences of doing that would be, but I don't think it's worth handling right now. The race window is really hard to hit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds reasonable to defer, thanks for creating the ticket. This behavior and our SDK piqued my curiosity so I dug into it a bit with my agent and had it write comments on these tickets with a suggestion for a slightly adjusted approach.

var message struct {
Method string `json:"method"`
}
if json.Unmarshal(raw, &message) == nil && message.Method != "" {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since the timer is still running, we may end up closing after a successful write while doing this post-processing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch 2 times, most recently from cb403d2 to 7082100 Compare October 23, 2026 11:14
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch from 7082100 to d4e261a Compare October 23, 2026 11:34

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pre-approving for when the 3 remaining issues are fixed.

Create dedicated harness sessions and keep their operations, status, and
transcripts in a session runtime. Attach callbacks during initialization,
retain ordered output, support cancellation and event watching, and close
manager-owned processes on shutdown. Unknown sessions return not found.

Runtime and lifecycle tests follow in the next change. Restoration and
agent API transport are separate changes.
@hugodutka
hugodutka force-pushed the hugodutka/acp-session-runtime branch from d4e261a to 07fdbd3 Compare October 26, 2026 16:01
@hugodutka
hugodutka merged commit 43ec0ba into main Oct 26, 2026
32 of 52 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 26, 2026
@hugodutka
hugodutka deleted the hugodutka/acp-session-runtime branch October 26, 2026 16:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants