feat(acp): keep the conversation when the AgentKit process restarts
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start in runtimes/common/agentkit_serve_common/acp.py, especially the state.history append around line 872, and read the existing session/new and session/cancel handling. Run the ACP tests and add coverage for saving, resuming and closing sessions, including the listed error cases and file permissions. Done means the process can resume prior conversation text without replaying history notifications, and close cancels work and removes saved history.
Written by the indexing model from the issue text.
Description
Problem
When Orka runs an AgentKit agent, it starts agentkit-serve --protocol acp as a child process, one process per conversation. Orka and that process talk over ACP, the Agent Client Protocol. ACP is a set of JSON messages for starting a conversation, which ACP calls a session, sending a prompt, and getting the answer back.
AgentKit keeps the conversation history only in that process's memory. If the process stops between two messages, the history is gone. A crash, running out of memory, or a kill can all cause this.
AgentKit has no way to pick a conversation back up, so the next message fails. Orka then starts a new session and hands it a shortened text copy of the chat that Orka keeps on its side. That copy keeps only the most recent 50 messages by default and leaves out tool call details. Long conversations lose context.
What
Add two ACP requests to AgentKit's ACP mode in runtimes/common/agentkit_serve_common/acp.py.
session/resumeconnects a fresh AgentKit process to an existing conversation by its session ID. The next prompt continues where the old process stopped.session/closeends a conversation cleanly when Orka deletes it. Today Orka can only stop the process.
Both requests are stable in ACP v1. See the ACP session setup docs.
Out of scope:
session/load. It sends the whole conversation back to the caller, and the ACP v2 draft removes it.session/fork. ACP still marks it unstable, so its shape can change.- Keeping a conversation after Orka replaces the whole runtime Pod. Each session's files live in a temporary directory that goes away with the Pod.
Why
Orka is adding its side of this in orka-agents/orka#737. When an agent process stops between messages, Orka's supervisor, the program that starts and watches agent processes, starts a new one and sends session/resume. It only does this if the agent says it supports resume. Codex, Claude and OpenCode already do. AgentKit doesn't, so AgentKit conversations still fall back to the shortened copy.
With this change, an AgentKit conversation keeps its full history when the process restarts. Orka would use the shortened copy only when resume really can't work, for example after the Pod is replaced.
How
- Save the history to a file. After each successful prompt, right where
acp.pyappends tostate.historyaround line 872, write the history to$XDG_STATE_HOME/agentkit/sessions/<session-id>.json. Orka gives every session its own privateXDG_STATE_HOME. Fall back to~/.local/statewhen the variable isn't set. Write to a temp file first and then rename it, so a crash never leaves a half-written file. Create the file with mode0600. Save only the user and assistant text thathistoryalready holds. Never write environment variables, tokens or provider settings. - Say that resume and close work. In the
initializeresponse, change"sessionCapabilities": {}to{"resume": {}, "close": {}}. - Handle
session/resume. Run the same checks assession/new. That means one session per process, acwdthat matches the process working directory, at most one MCP server, and noadditionalDirectories. Check that the session ID looks likeagentkit-plus 32 hex characters before you use it in a file path. Load the saved history, build the runtime the same way_create_sessiondoes, and register the session under the same ID. Don't send the old messages back assession/updatenotifications, because the spec says resume must not replay history. If the file is missing or can't be parsed, return a JSON-RPC error. Orka then falls back to its own copy, which is the safe outcome. - Handle
session/close. Cancel any running prompt the same waysession/canceldoes, shut down the runtime, and delete the history file.
Done when
initializereportsresumeandcloseundersessionCapabilities.- A test starts the ACP process, sends a prompt that states a fact, kills the process, starts a new one, resumes the session, and asks about that fact. The model request carries the earlier history, and the process sends no history back as notifications.
- Resume returns a clear error for an unknown ID, a malformed ID, a missing or corrupt file, and a different
cwd. session/closecancels a running prompt and deletes the history file.- The history file has mode
0600and contains only conversation text. - After this lands, the runtime support table that orka-agents/orka#737 adds to
workers/acp/images/README.mdcan list AgentKit as supporting resume and close.
- Dominant language
- Python
- Stars
- 7
- Forks
- 5
- Avg merge
- 3h 39m
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from orka-agents/agentkit
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)Possibly taken @gambtho claimed this 30 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
orka-agents/agentkit#77 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
orka-agents/agentkit#76 · 3 comments ·
-
area/build area/orka area/runtime blocked enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
Difficulty 4/5 3-5 days Newbie friendliness 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement testing
Difficulty 5/5 Over a week Newbie friendliness 42/100
orka-agents/agentkit#65 ·
All issues in orka-agents/agentkit
Similar issues
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 62/100
DaoCloud/DaoCloud-docs#7839 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
sav-oss-org/ptusa_main#1610 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug status/accepted type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
microsoft/apm#4925 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
sagemathinc/sagebrush#1701 ·
Maintainers usually reply within 1 day