Skip to content

Expose SDK broker exit notifications#947

Merged
khaliqgant merged 4 commits into
mainfrom
codex/issue-945-broker-exit
May 22, 2026
Merged

Expose SDK broker exit notifications#947
khaliqgant merged 4 commits into
mainfrom
codex/issue-945-broker-exit

Conversation

@khaliqgant

Copy link
Copy Markdown
Member

Summary

  • Add AgentRelayClient.onBrokerExit() and exported BrokerExitInfo for SDK-spawned brokers
  • Capture exit code, signal, PID, and recent stderr, replaying the exit to late subscribers
  • Clear brokerPid after managed broker exit and skip event/lease setup if the child dies during startup
  • Document the hook and add changelog/test coverage

Fixes #945

Verification

  • npm exec vitest run --config vitest.config.ts src/__tests__/client-broker-exit.test.ts
  • npm exec vitest run --config vitest.config.ts src/__tests__/client-stdout-drain.test.ts
  • npm --prefix packages/sdk run check
  • npx tsc -p tsconfig.build.json
  • git diff --check -- CHANGELOG.md packages/sdk/README.md packages/sdk/src/client.ts packages/sdk/src/index.ts packages/sdk/src/workers.ts packages/sdk/src/__tests__/client-broker-exit.test.ts

Proactive Runtime Bot and others added 3 commits May 21, 2026 20:06
The broker name is otherwise derived from the project directory basename,
which means re-running `up` against a workspace that already has an agent
with that name fails the relaycast handshake with
`agent name '<name>' already exists`. The only existing workarounds were
to rename the project directory or rotate the workspace key.

Threads a `brokerName` option through `UpOptions`,
`CoreDependencies.createRelay`, `createDefaultRelay`, and
`createAgentRelayClient` into the SDK's `AgentRelayClient.spawn`, which
already supported it. Also forwards `--broker-name` from background
re-execs in `childUpArgsForDetachedStart` so programmatic callers (not
just CLI users whose argv is preserved verbatim) get the override.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@khaliqgant khaliqgant requested a review from willwashburn as a code owner May 22, 2026 13:58
@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@khaliqgant has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 46 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a617531-36ec-49bf-8c07-dea3e32c0e0f

📥 Commits

Reviewing files that changed from the base of the PR and between 90dc1fa and cd6bde4.

📒 Files selected for processing (13)
  • .trajectories/completed/2026-05/traj_dcl9hgoiuac5.json
  • .trajectories/completed/2026-05/traj_dcl9hgoiuac5.md
  • .trajectories/index.json
  • CHANGELOG.md
  • packages/openclaw/src/identity/files.ts
  • packages/sdk/README.md
  • packages/sdk/src/__tests__/client-broker-exit.test.ts
  • packages/sdk/src/client.ts
  • packages/sdk/src/index.ts
  • packages/sdk/src/workers.ts
  • src/cli/commands/core.test.ts
  • web/content/docs/cli-broker-lifecycle.mdx
  • web/content/docs/local-mode.mdx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-945-broker-exit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 15 files

Re-trigger cubic

@khaliqgant khaliqgant merged commit bbe4f00 into main May 22, 2026
60 of 61 checks passed
@khaliqgant khaliqgant deleted the codex/issue-945-broker-exit branch May 22, 2026 15:28
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.

@agent-relay/sdk: expose broker child-process exit so consumers can react

1 participant