{"record":{"id":"5a4c46155df3bd96","repo":"vercel/ai","slug":"acp-v1-does-not-define-manual-session-compaction","errorCode":null,"errorMessage":"ACP v1 does not define manual session compaction.","messagePattern":"ACP v1 does not define manual session compaction\\.","errorType":"exception","errorClass":"HarnessCapabilityUnsupportedError","httpStatus":null,"severity":"error","filePath":"packages/harness-acp/src/v1/acp-v1-harness.ts","lineNumber":1581,"sourceCode":"                  instructionMapping,\n                  ...(options.instructions == null\n                    ? {}\n                    : { instructions: options.instructions }),\n                }),\n            ...(mcpServers == null ? {} : { mcpServers }),\n            tools: turnStartConfig.tools,\n            turnStartConfig,\n            recoveryMode: {\n              type: 'lossy-rerun',\n              acpSessionId: latestACPSessionId!,\n              reason: recoveryStatus?.reason ?? 'bridge process loss',\n            },\n          });\n        },\n      });\n    },\n    doCompact: async () => {\n      throw unsupported({\n        harnessId,\n        message: 'ACP v1 does not define manual session compaction.',\n      });\n    },\n    doSuspendTurn: async () => {\n      if (stopped) {\n        throw new Error(\n          `${harnessId} ACP session ${sessionId} is stopped; cannot suspend.`,\n        );\n      }\n      if (!turnInFlight) {\n        throw new Error(\n          `${harnessId} ACP session ${sessionId} has no in-flight turn to suspend.`,\n        );\n      }\n      stopped = true;\n      const lastSeenEventId = await channel.suspend();\n      return {","sourceCodeStart":1563,"sourceCodeEnd":1599,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-acp/src/v1/acp-v1-harness.ts#L1563-L1599","documentation":"The ACP v1 harness implements doCompact as an unconditional 'unsupported' throw because the ACP protocol version 1 defines no manual session-compaction operation. Any call to compact the session will always fail; compaction is not a capability of this transport.","triggerScenarios":"Explicitly invoking the session's doCompact / compact API on a session created via createACPV1.","commonSituations":"Writing harness-agnostic code that unconditionally calls compaction on every session; long-running agent sessions approaching context limits where an ACP backend is in use.","solutions":["Do not call compaction on ACP v1 sessions; gate the call on a capability check or harness type.","Start a new session instead of compacting when context grows too large.","Wait for/upgrade to an ACP protocol version that defines compaction, if one becomes available."],"exampleFix":"// before\nawait session.compact();\n// after\nif (supportsCompaction(harnessId)) {\n  await session.compact();\n} else {\n  session = await recreateSession();\n}","handlingStrategy":"type-guard","validationCode":"if (harnessId.startsWith('acp') || isACPHarness(session)) {\n  throw new Error('Manual compaction is not supported on ACP v1 sessions');\n}","typeGuard":"function supportsCompaction(session: { harnessId?: string }): boolean {\n  return !(session.harnessId ?? '').toLowerCase().includes('acp');\n}","tryCatchPattern":"try {\n  await session.compact();\n} catch (e) {\n  if (String(e?.message).includes('manual session compaction')) {\n    session = await recreateSession(); // restart instead of compacting\n  } else throw e;\n}","preventionTips":["Gate compaction behind a capability query on the session","Never call compaction unconditionally in harness-agnostic loops","Plan context management (new session) for ACP-backed long runs"],"tags":["acp","compaction","unsupported-capability"],"backgroundTag":"unsupported-capability","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}