Skip to content

feat: emit origin_actor from spawned agents (JS SDK + per-worker)#1090

Merged
willwashburn merged 2 commits into
mainfrom
feat/origin-actor-js
Jun 11, 2026
Merged

feat: emit origin_actor from spawned agents (JS SDK + per-worker)#1090
willwashburn merged 2 commits into
mainfrom
feat/origin-actor-js

Conversation

@willwashburn

Copy link
Copy Markdown
Member

Completes the origin_actor producer rollout for the JS spawned-agent path (~23%) — the piece the core (broker's own agent-relay-cli/cli, v8.3.6) didn't cover. Consumes @relaycast/sdk 3.1.1 (relaycast#187), which renamed the harness option → originActor / X-Relaycast-Origin-Actor.

JS

  • relaycast-telemetry.ts (cli + sdk): resolve originActor from a new AGENT_RELAY_ORIGIN_ACTOR env (the broker sets the per-worker path), falling back to agent-relay-cli/agent/<orchestrator-harness> synthesized from the existing harness env. relaycastTelemetryOptions now returns { originActor }.
  • messaging/relaycast.ts: pass originActor.
  • Bump @relaycast/sdk ^2.x → ^3.1.1 (cli + sdk) + lockfile.

Broker (supersedes the open #1078)

  • spawn_env_vars: set AGENT_RELAY_ORIGIN_ACTOR=agent-relay-cli/agent/<harness> (was AGENT_RELAY_HARNESS), with the per-worker harness from infer_harness_from_command(params.cli) (was the orchestrator harness).
  • worker.rs (pty/app-server): stamp the same path from spec.cli.
  • infer_harness_from_commandpub(crate).

Result

Each spawned JS agent reports agent-relay-cli/agent/<its-harness> (codex / claude-code / …), per-agent — closing the 23%.

Verification

  • 713 broker tests pass; clippy + fmt --check clean.
  • sdk tsc clean; agent-relay (6) + mcp.startup (20) JS tests pass.
  • The cli typecheck against the real 3.1.1 is left to CI (the local symlink resolves 2.5.1; verified 3.1.1 publishes both originActor and the model spawn field, so it'll compile).

Closes

Supersedes #1078 (per-worker attribution) — please close it in favor of this.

🤖 Generated with Claude Code

Completes the origin_actor producer rollout for the JS spawned-agent path
(the ~23%). Consumes @relaycast/sdk 3.1.1 (relaycast#187), which renamed the
`harness` option -> `originActor` / `X-Relaycast-Origin-Actor`.

JS:
- relaycast-telemetry.ts (cli + sdk): resolve `originActor` from a new
  AGENT_RELAY_ORIGIN_ACTOR env (the broker sets the per-worker path), falling
  back to `agent-relay-cli/agent/<orchestrator-harness>` synthesized from the
  existing harness env. `relaycastTelemetryOptions` now returns `{ originActor }`.
- messaging/relaycast.ts: pass `originActor`.
- bump @relaycast/sdk ^2.x -> ^3.1.1 (cli + sdk) + lockfile.

Broker (supersedes the open #1078):
- spawn_env_vars: set AGENT_RELAY_ORIGIN_ACTOR=agent-relay-cli/agent/<harness>
  (was AGENT_RELAY_HARNESS), with the per-worker harness from
  infer_harness_from_command(params.cli) (was the orchestrator harness).
- worker.rs (pty/app-server): stamp the same path from spec.cli.
- infer_harness_from_command -> pub(crate).

Result: each spawned JS agent reports `agent-relay-cli/agent/<its-harness>`
(codex / claude-code / …), per-agent — closing the 23% the core (broker-own,
agent-relay-cli/cli) didn't cover.

713 broker tests pass; clippy + fmt clean; sdk tsc clean; agent-relay (6) +
mcp.startup (20) JS tests pass. The cli typecheck vs the real 3.1.1 is left to
CI (verified 3.1.1 has originActor + the model spawn field).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@willwashburn willwashburn requested a review from khaliqgant as a code owner June 11, 2026 00:20
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 699254b9-d7f3-4425-b8eb-bd74b0c3384d

📥 Commits

Reviewing files that changed from the base of the PR and between 9fe26de and e468815.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (11)
  • crates/broker/src/spawner.rs
  • crates/broker/src/telemetry.rs
  • crates/broker/src/worker.rs
  • crates/broker/src/wrap.rs
  • packages/cli/package.json
  • packages/cli/src/cli/agent-relay-mcp.startup.test.ts
  • packages/cli/src/cli/lib/relaycast-telemetry.ts
  • packages/sdk/package.json
  • packages/sdk/src/__tests__/agent-relay.test.ts
  • packages/sdk/src/messaging/relaycast.ts
  • packages/sdk/src/relaycast-telemetry.ts

📝 Walkthrough

Walkthrough

This PR migrates telemetry attribution from a harness field to originActor across SDK, CLI, and broker components. The originActor is resolved from an explicit AGENT_RELAY_ORIGIN_ACTOR environment variable or synthesized from harness environment variables, and is injected into spawned processes in the format agent-relay-cli/agent/{harness}.

Changes

Origin Actor Telemetry Migration

Layer / File(s) Summary
Telemetry origin actor resolution contracts
packages/cli/src/cli/lib/relaycast-telemetry.ts, packages/sdk/src/relaycast-telemetry.ts
SDK and CLI define ORIGIN_ACTOR_ENV constant and update RelaycastTelemetryOptions interface to replace harness field with originActor.
Telemetry resolution implementation
packages/cli/src/cli/lib/relaycast-telemetry.ts, packages/sdk/src/relaycast-telemetry.ts
Implement resolveOriginActor() to compute from explicit AGENT_RELAY_ORIGIN_ACTOR environment variable or synthesize from harness environment variables with agent-relay-cli/agent/ prefix.
Broker harness inference foundation
crates/broker/src/telemetry.rs
Expose infer_harness_from_command as pub(crate) with documentation mapping CLI command names to canonical harness IDs.
Broker spawned process environment injection
crates/broker/src/spawner.rs
Update spawn_env_vars to inject AGENT_RELAY_ORIGIN_ACTOR formatted as agent-relay-cli/agent/{harness}, and update unit tests to verify presence/absence of the new environment variable.
Broker per-worker origin actor injection
crates/broker/src/worker.rs
Conditionally inject AGENT_RELAY_ORIGIN_ACTOR into worker spawn environment when not explicitly provided, inferring harness from worker CLI.
Broker spawn call site update
crates/broker/src/wrap.rs
Update spawn call site to infer harness from child cli parameter instead of using orchestrator_harness_opt().
SDK Relaycast client telemetry wiring
packages/sdk/src/messaging/relaycast.ts
Wire originActor through createRelaycastClient by passing resolved originActor to relaycastTelemetryOptions().
SDK test validation for originActor
packages/sdk/src/__tests__/agent-relay.test.ts
Update multiple test cases to expect originActor in Relaycast client configuration, validating explicit and environment-derived resolution paths.
CLI MCP startup test validation
packages/cli/src/cli/agent-relay-mcp.startup.test.ts
Update test to stub AGENT_RELAY_ORIGIN_ACTOR and validate originActor appears in Relay/WebSocket client configuration.
Dependency version updates
packages/cli/package.json, packages/sdk/package.json
Update @relaycast/sdk dependency from ^2.x.x to ^3.1.1 in both packages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AgentWorkforce/relay#1069: Also modifies the broker harness/telemetry forwarding pipeline in crates/broker/src/spawner.rs and the harness parameter wiring into child environment variables.

Suggested reviewers

  • khaliqgant

Poem

🐰 From harness to origin, we trace the way,
Each spawned child now knows its agent's sway.
The relay whispers agent-relay-cli/agent/ names,
Through broker dust and telemetry flames.
Onward hops our migration, clear and bright! 🌟

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/origin-actor-js

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.

@willwashburn willwashburn merged commit f87fa77 into main Jun 11, 2026
1 of 2 checks passed
@willwashburn willwashburn deleted the feat/origin-actor-js branch June 11, 2026 00:22

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8f737f2c06

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const harness =
nonEmpty(explicit.harness) ??
HARNESS_ENV_KEYS.map((key) => nonEmpty(env[key])).find((value): value is string => Boolean(value));
const originActor = nonEmpty(explicit.originActor) ?? resolveOriginActor(env);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the deprecated harness telemetry option

When existing @agent-relay/sdk callers still pass the previously supported harness option to AgentRelay or RelaycastMessagingClient (especially JavaScript callers that are not type-checked), this now ignores it because only explicit.originActor is read before constructing the Relaycast client. Since the package remains on the same 8.3.x line, those clients silently stop sending attribution rather than being mapped to the new originActor; keeping harness as a deprecated alias here would avoid dropping telemetry during the rollout.

Useful? React with 👍 / 👎.

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