Skip to content

fix(agents): preserve ACP requester agent overrides - #55708

Closed
RichardCao wants to merge 1 commit into
openclaw:mainfrom
RichardCao:fix/acp-requester-agent-override
Closed

RichardCao wants to merge 1 commit into
openclaw:mainfrom
RichardCao:fix/acp-requester-agent-override

Conversation

@RichardCao

Copy link
Copy Markdown
Contributor

Summary

  • pass requesterAgentIdOverride through the ACP sessions_spawn path
  • resolve ACP requester heartbeat/relay eligibility from the explicit override before falling back to the parent session key
  • add regression coverage for the tool passthrough and for implicit parent-stream gating using the overridden requester agent

Testing

  • pnpm exec vitest run src/agents/tools/sessions-spawn-tool.test.ts src/agents/acp-spawn.test.ts

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S r: too-many-prs Auto-close: author has more than twenty active PRs. labels Mar 27, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 10 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

@greptile-apps

greptile-apps Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where requesterAgentIdOverride was not being forwarded through the ACP sessions_spawn path (sessions-spawn-tool.ts → spawnAcpDirect), causing heartbeat/relay eligibility to be resolved against the parent session key's agent instead of the intended override agent. The fix is minimal and surgical — three lines to thread the override into SpawnAcpContext, then use it with the correct ??-fallback in both isHeartbeatEnabledForSessionAgent and resolveAcpSpawnRequesterState.\n\nKey changes:\n- sessions-spawn-tool.ts: adds requesterAgentIdOverride: opts?.requesterAgentIdOverride to the context object passed to spawnAcpDirect (was already present for the spawnSubagentDirect path)\n- acp-spawn.ts: adds requesterAgentIdOverride?: string to SpawnAcpContext; resolves the effective requester agent ID via normalizeOptionalAgentId(override) ?? parsedSession?.agentId in both the heartbeat-enabled check and the resolveAcpSpawnRequesterState function\n- Regression tests cover the tool passthrough and the implicit parent-stream gate being correctly suppressed when the override agent lacks a heartbeat configuration

Confidence Score: 5/5

Safe to merge — targeted two-site fix with no behavioural regressions and new regression coverage added.

All changed logic is correct: the override is applied with a ?? fallback in both heartbeat-eligibility sites, and the normalizeOptionalAgentId guard handles empty/null gracefully. The hasSessionLocalHeartbeatRelayRoute store-path lookup uses the effective requesterAgentId, which is correct given the documented intent of the override (cron/hook sessions where the session key already belongs to the override agent). Tests directly cover the new passthrough and the eligibility path. No P0 or P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
src/agents/acp-spawn.ts Adds requesterAgentIdOverride to SpawnAcpContext and threads it through heartbeat eligibility checks with correct fallback logic.
src/agents/tools/sessions-spawn-tool.ts Forwards requesterAgentIdOverride into the spawnAcpDirect context, matching the existing subagent path.
src/agents/acp-spawn.test.ts Adds regression test verifying override agent identity suppresses implicit parent-stream relay when override agent lacks heartbeat config.
src/agents/tools/sessions-spawn-tool.test.ts Adds assertion confirming requesterAgentIdOverride is passed through to spawnAcpDirect on the ACP runtime path.

Reviews (1): Last reviewed commit: "fix(agents): preserve ACP requester agen..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling r: too-many-prs Auto-close: author has more than twenty active PRs. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant