Skip to content

test: E2E scenario for subagent compression - #192

Merged
ranxianglei merged 2 commits into
masterfrom
2026-07-23_subagent-e2e-test
Jul 25, 2026
Merged

test: E2E scenario for subagent compression#192
ranxianglei merged 2 commits into
masterfrom
2026-07-23_subagent-e2e-test

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Summary

Adds an E2E test scenario that verifies ACP compression works correctly inside subagent (child) sessions. This is a regression guard for PR #180 (remove subagent history rewriting) — confirms the deleted feature didn't break subagent compression.

What it tests

  • Parent spawns a subagent via the task tool (subagent_type: "general")
  • Child session accumulates 3 bash tool outputs
  • Child calls compress(m00001-m00003) with a hand-written summary
  • Verifies: parent session has 0 blocks, child session has 1 block

Changes

No production code changes — only test/script infrastructure.

File Change
scripts/e2e/fake-llm-server.ts Child session detection via x-parent-session-id HTTP header; handleChildRequest() routes child turns from subagent_turns array; handleTaskStep() emits task tool_use; generic toolUseResponse() SSE streaming; extractMessageText fixed to search tool_calls[].function.arguments (ACP injects <dcp-message-id> tags into tool-call-only assistant messages)
scripts/e2e/scenarios/05-subagent-compress.json NEW scenario: parent emits task, child runs 3× bash → compress → text
scripts/e2e/run-e2e.sh Added agent.general definition, task/bash permissions, experimental.allowSubAgents: true, pass ACP_DIR to verify.ts
scripts/e2e/verify.ts Added childBlockCount assertion; discovers child state files by scanning ACP directory
devlog/2026-07-23_subagent-e2e-test/{REQ,WORKLOG}.md Devlog

Key finding

ACP's production code (lib/hooks.ts, lib/message-ids.ts) requires no changes for subagent compression — existing code handles it correctly when experimental.allowSubAgents: true is set. OpenCode sends x-parent-session-id on child session LLM requests (source: session/llm/request.ts:187-205).

Verification

  • npm run typecheck
  • npm test → 846 pass ✅
  • E2E (original branch): 5 scenarios pass, 0 fail ✅

Branch state

Rebased on current master (v1.13.7-dev.1, commit 5e4b309) — 2 commits cherry-picked cleanly, no conflicts.

Ultraworked with Sisyphus

Co-authored-by: Sisyphus clio-agent@sisyphuslabs.ai

ranxianglei and others added 2 commits July 25, 2026 11:32
Add x-parent-session-id header detection to distinguish parent vs child
LLM requests. Add handleChildRequest() for subagent turn routing,
handleTaskStep() for task tool emission, and toolUseResponse() for
generic SSE streaming. Fix extractMessageText to search tool_calls
arguments where ACP injects message-ID tags for tool-call-only
assistant messages.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
New scenario 05-subagent-compress verifies ACP compression works
inside subagent sessions: parent emits task tool, child accumulates
3 bash calls, compresses m00001-m00003, verifies childBlockCount=1.
Harness updated with allowSubAgents config, general agent definition,
and child state file discovery in verify.ts.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@ranxianglei
ranxianglei merged commit c149686 into master Jul 25, 2026
4 checks passed
ranxianglei added a commit that referenced this pull request Jul 25, 2026
…ress (#195)

Scenario 05 set acknowledgeRisk=true on the FIRST compress call inside the
subagent. This flag is only valid when retrying after a quality gate rejection.
On a first attempt, the compress tool correctly rejects it, producing 0 blocks.

Root cause: PR #192 copy-pasted from scenario 03 without noticing that scenario
03 nests acknowledgeRisk inside retryOnReject.

Fix: remove the flag. Verified passing on both master and PR #184.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant