feat(acp): keep the conversation when the AgentKit process restarts
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 7
- Fork
- 5
- Merge medio
- 3h 39m
- PR unite (30g)
- 1
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di orka-agents/agentkit
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)Forse già presa @gambtho l’ha presa 30 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
orka-agents/agentkit#77 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
orka-agents/agentkit#76 · 3 commenti ·
-
area/build area/orka area/runtime blocked enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement testing
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
orka-agents/agentkit#65 ·
Tutte le issue di orka-agents/agentkit
Issue simili
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DaoCloud/DaoCloud-docs#7839 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
sav-oss-org/ptusa_main#1610 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug status/accepted type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/apm#4925 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sagemathinc/sagebrush#1701 ·
I maintainer di solito rispondono entro 1 giorno