Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

test(agent-runtime): cover resumed carrier identity

vastsab9afccca561a
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 4b4eb023e..a5f9305c2 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -11906,7 +11906,8 @@ This test plan spec is accepted when:
- **Preconditions**: The same injected small-window fake provider. One settled
`reader` chain read enough to exceed the delegate hard limit while staying
under `MAX_RESUMABLE_READ_LINES`; a second settled chain fits well inside
- the budget.
+ the budget. The resumed fixture uses `vendorKey: "deepseek"` and includes a
+ persisted assistant row with both answer text and thinking.
- **Steps**:
1. `Task.resume` the over-budget chain and capture its first provider
request in full.
@@ -11917,6 +11918,8 @@ This test plan spec is accepted when:
the over-budget chain again.
5. Accumulate more than `MAX_RESUMABLE_READ_LINES` of read-only output in a
chain and read the reusable list the next prompt offers.
+ 6. Inspect the resumed assistant history in the captured request and verify
+ its same-model reasoning remains in `reasoning_content`.
- **Expected**: The first request of a resumed run is below the hard limit. It
opens with the original task brief and holds the most recent turns; the
oldest tool results are dropped first, and dropping an assistant message
@@ -11925,8 +11928,11 @@ This test plan spec is accepted when:
conclusion is answered from the seeded context; the first round's may be
gone, and the run says so rather than inventing it. A resume never fails
with `CONTEXT_TOO_LARGE` or `SUBAGENT_CONTEXT_OVERFLOW` on its first
- request. `MAX_RESUMABLE_READ_LINES` still removes an over-read chain from
- the reusable list; truncation does not make it resumable again.
+ request. With a vendorKey binding, restored assistant history uses the same
+ `model.provider` / `model.id` identity as live requests, and its thinking
+ stays in the native `reasoning_content` field. `MAX_RESUMABLE_READ_LINES`
+ still removes an over-read chain from the reusable list; truncation does not
+ make it resumable again.
- **Specs linked**: `03-runtime/02-agent-runtime.md` §5f, ADR 0299, ADR 0279
- **Acceptance criterion**: C — Conversation & stream; Quality
- **Milestone**: M6+
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 1c6b67558..36eacd1b8 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -4758,7 +4758,8 @@ eleven-tool-round desktop paths are verified by
- **先决条件**:同一个注入的小窗口伪提供商。一条已结算的 `reader` 链读取的内容
足以超出委托的硬边界,但仍在 `MAX_RESUMABLE_READ_LINES` 以内;第二条已结算的
- 链远远落在预算之内。
+ 链远远落在预算之内。恢复场景使用 `vendorKey: "deepseek"`,且转录中有一条
+ 同时含有回答文本与思考内容的助手消息。
- **步骤**:
1. 对超出预算的那条链执行 `Task.resume`,完整捕获它的第一次提供商请求。
2. 对落在预算之内的那条链执行 `Task.resume`,捕获同样的请求。
@@ -4766,13 +4767,15 @@ eleven-tool-round desktop paths are verified by
4. 重启应用,从转录重建链索引,再次恢复那条超出预算的链。
5. 在一条链里累积超过 `MAX_RESUMABLE_READ_LINES` 的只读输出,读取下一条提示给出
的可复用清单。
+ 6. 检查捕获请求中的恢复助手历史,确认同模型思考仍位于 `reasoning_content`。
- **预期**:恢复后运行的第一次请求低于硬边界。它以原始任务简报开头,并保有最近的
若干轮;最旧的工具结果优先被丢弃,而丢弃一条助手消息会连同它的工具调用一起丢弃,
因此没有孤立的工具调用会到达提供商。落在预算之内的链仍按原样整条播种。最近一轮的
结论能从播种的上下文里答出;第一轮的结论可能已经不在,此时该次运行会照实说明,而
不是凭空编造。一次恢复绝不会在它的第一次请求上以 `CONTEXT_TOO_LARGE` 或
- `SUBAGENT_CONTEXT_OVERFLOW` 失败。`MAX_RESUMABLE_READ_LINES` 仍然会把读取过多的链
- 移出可复用清单;裁剪不会让它重新变得可恢复。
+ `SUBAGENT_CONTEXT_OVERFLOW` 失败。使用 `vendorKey` 绑定时,恢复助手历史使用与实时请求
+ 相同的 `model.provider` / `model.id` 身份,思考内容仍在原生 `reasoning_content` 字段中。
+ `MAX_RESUMABLE_READ_LINES` 仍然会把读取过多的链移出可复用清单;裁剪不会让它重新变得可恢复。
- **链接规格**:`03-runtime/02-agent-runtime.md` §5f、ADR 0299、ADR 0279
- **验收**:C — 对话和直播;品质
- **里程碑**:M6+
diff --git a/packages/agent-runtime/src/resume-provider-identity.test.ts b/packages/agent-runtime/src/resume-provider-identity.test.ts
index 1c8cbce7e..571b6a59d 100644
--- a/packages/agent-runtime/src/resume-provider-identity.test.ts
+++ b/packages/agent-runtime/src/resume-provider-identity.test.ts
@@ -14,7 +14,7 @@ import { contextBudgetLimitsFor } from "./context-budget.js";
* reasoning_content. Tagging with the account row id instead makes the
* adapter treat the history as foreign-model and empties that field.
*/
-function replay(vendorKey?: string) {
+function replay(vendorKey?: string, rows?: UiMessage[]) {
const provider: RuntimeProviderConfig = {
id: "account-row-uuid",
vendorKey,
@@ -28,7 +28,7 @@ function replay(vendorKey?: string) {
const model = buildProviderModel(provider);
const originalThinking =
"Inspect the authorization boundary before reading the file.";
- const rows: UiMessage[] = [
+ const transcriptRows: UiMessage[] = rows ?? [
{
id: "assistant-1",
role: "assistant",
@@ -48,7 +48,7 @@ function replay(vendorKey?: string) {
];
const messages = seedDelegateMessages({
originalTask: "Inspect permissions.",
- rows,
+ rows: transcriptRows,
provider,
model,
budget: contextBudgetLimitsFor(model),
@@ -91,3 +91,24 @@ it("control: the old no-vendor-key binding preserves reasoning", () => {
const { assistant, originalThinking } = replay();
expect(assistant?.reasoning_content).toBe(originalThinking);
});
+
+it("tags synthetic tool-call carriers with the transport model identity", () => {
+ const { messages, model } = replay("deepseek", [
+ {
+ id: "result-1",
+ role: "tool",
+ content: "file contents",
+ toolCallId: "call-1",
+ toolName: "Read",
+ toolArgs: { path: "permissions.ts" },
+ createdAt: "2026-10-10T00:00:01.000Z",
+ },
+ ]);
+ const carrier = messages.find((message) => message.role === "assistant");
+
+ expect(carrier).toMatchObject({
+ provider: model.provider,
+ model: model.id,
+ stopReason: "toolUse",
+ });
+});