Skip to content

test(app-server): cover external-agent cancellation and approval paths#187

Open
andrei-hasna wants to merge 3 commits into
mainfrom
openloops/open-codewith/5ddd56e4-0f42-4530-9707-6c8b70630e33-8a59d29e
Open

test(app-server): cover external-agent cancellation and approval paths#187
andrei-hasna wants to merge 3 commits into
mainfrom
openloops/open-codewith/5ddd56e4-0f42-4530-9707-6c8b70630e33-8a59d29e

Conversation

@andrei-hasna

Copy link
Copy Markdown
Contributor

Summary

Adds regression coverage for live external-agent runs before /external-agent execution is ungated, per todos task 5ddd56e4. Tests only — no product behavior changes; the current deny/reject gating is asserted as a regression guard.

Unit tests (thread_external_agent_processor)

  • Terminal events (Completed/Failed/Cancelled) mark the run terminal (so execute() cannot double-emit Failed); progress events (Status/ProposedAction) do not.
  • Terminal events with no subscribers are dropped yet still recorded as terminal (late-event filtering).
  • Events fan out to every subscribed connection.
  • request_permission denies by default (RejectOnce) — approval-denial guard.
  • perform_action rejects managed actions with the exact gating reason and emits a ProposedAction notification — action-routing-failure guard.
  • is_cancelled tracks the CancellationToken.

Integration tests (suite/v2/thread_external_agent)

  • Cancel rejects empty and unknown run ids with the expected messages.
  • An active live run reaches a terminal event and is removed from the active-run registry, so a follow-up cancel reports it inactive. Terminal event is accepted as Cancelled or Failed so the registry-cleanup guarantee holds regardless of sandbox availability.

Validation

  • cargo test -p codex-app-server --lib external_agent — 63 passed.
  • cargo test -p codex-app-server --test all thread_external_agent_cancel — 2 new integration tests pass.
  • cargo fmt --all, cargo clippy -p codex-app-server --all-targets — clean.

Note: the pre-existing thread_external_agent_start_emits_run_event_and_validates_runtime test asserts the claude runtime is gated on "missing runtime"; it fails in environments where a real claude binary is on PATH. This is environment-dependent and untouched by this change.

🤖 Generated with Claude Code

Add regression coverage for the live external-agent host and cancel RPC
before /external-agent execution is ungated. These assert the current
deny/reject gating so it cannot silently regress.

Unit tests (thread_external_agent_processor):
- terminal events (Completed/Failed/Cancelled) mark the run terminal so
  execute() does not double-emit Failed; progress events do not.
- terminal events with no subscribers are dropped yet still recorded.
- events fan out to every subscribed connection (late-event gating).
- request_permission denies by default (RejectOnce).
- perform_action rejects managed actions with the gating reason and emits
  a ProposedAction notification (action-routing-failure guard).
- is_cancelled tracks the CancellationToken.

Integration tests (suite/v2/thread_external_agent):
- cancel rejects empty and unknown run ids with the expected messages.
- an active run reaches a terminal event and is removed from the active-run
  registry so a follow-up cancel reports it inactive.
@andrei-hasna
andrei-hasna force-pushed the openloops/open-codewith/5ddd56e4-0f42-4530-9707-6c8b70630e33-8a59d29e branch from 864038b to e55eb11 Compare July 9, 2026 13:00
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