Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .agents/skills/using-agent-relay/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ remove_agent(name: "reviewer-1", reason: "Review accepted")

## Current CLI Reference

Startup and status commands are intentionally omitted from these agent-facing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: The new security note says status commands are omitted because they can print live workspace credentials in a transcribed session, yet the same CLI reference block still lists agent-relay status as the first safe example. If agent-relay status behaves like the removed node status/node up commands, this leaves a credential-printing command in the examples; if it is genuinely safe, the note's blanket 'status commands' wording is misleading. Consider clarifying whether agent-relay status is safe (and if not, remove it) so an agent in a transcribed session isn't misled into running it.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .agents/skills/using-agent-relay/SKILL.md, line 192:

<comment>The new security note says status commands are omitted because they can print live workspace credentials in a transcribed session, yet the same CLI reference block still lists `agent-relay status` as the first safe example. If `agent-relay status` behaves like the removed `node status`/`node up` commands, this leaves a credential-printing command in the examples; if it is genuinely safe, the note's blanket 'status commands' wording is misleading. Consider clarifying whether `agent-relay status` is safe (and if not, remove it) so an agent in a transcribed session isn't misled into running it.</comment>

<file context>
@@ -189,13 +189,16 @@ remove_agent(name: "reviewer-1", reason: "Review accepted")
 
 ## Current CLI Reference
 
+Startup and status commands are intentionally omitted from these agent-facing
+examples. Published Agent Relay versions through 11.3.0 can print live
+workspace credentials when those commands run in a transcribed session. Upgrade
</file context>

examples. Published Agent Relay versions through 11.3.0 can print live
workspace credentials when those commands run in a transcribed session. Upgrade
to Agent Relay 11.3.1 or later before running them there.
Comment on lines +192 to +195

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file around lines =="
nl -ba .agents/skills/using-agent-relay/SKILL.md | sed -n '170,215p'

echo
echo "== related commands in file =="
rg -n "agent-relay|node status|node up|credentials|Agent Relay|workspace credentials|11\.3\.[01]" .agents/skills/using-agent-relay/SKILL.md

echo
echo "== git diff context if available =="
git diff -- .agents/skills/using-agent-relay/SKILL.md | sed -n '1,220p' || true

Repository: AgentWorkforce/relay

Length of output: 222


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file around lines =="
awk '{printf "%5d\t%s\n", NR, $0}' .agents/skills/using-agent-relay/SKILL.md | sed -n '170,215p'

echo
echo "== related commands in file =="
rg -n "agent-relay|node status|node up|credentials|Agent Relay|workspace credentials|11\.3\.[01]" .agents/skills/using-agent-relay/SKILL.md || true

echo
echo "== git diff context if available =="
git diff -- .agents/skills/using-agent-relay/SKILL.md 2>/dev/null | sed -n '1,220p' || true

Repository: AgentWorkforce/relay

Length of output: 4530


Name the omitted commands and fix the credential-safety wording.

Line 192 says startup and status commands are omitted, but agent-relay status is still listed. Line 193 also says Agent Relay versions through 11.3.0 can print live workspace credentials; use up to and including 11.3.0 if that applies, or remove agent-relay status if it is unsafe.

🧰 Tools
🪛 SkillSpector (2.4.4)

[warning] 21: [AS3] Skill Enumeration: Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Remediation: Remove all code or instructions that list or read other skills' files or directories. Skills should operate independently; cross-skill access is a privilege escalation.

(Agent Snooping (AS3))


[warning] 54: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 75: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 90: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 92: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 93: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 94: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 95: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 98: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 227: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.agents/skills/using-agent-relay/SKILL.md around lines 192 - 195, Update the
agent-facing examples around the startup/status command guidance to explicitly
name the omitted commands and ensure the listed commands match that statement.
Correct the credential-safety wording to use “up to and including 11.3.0” if
both commands are unsafe; otherwise remove agent-relay status from the examples
and retain the warning for the unsafe command only.


These are the current CLI forms for local broker and SDK-backed messaging
operations:

```bash
agent-relay status
agent-relay node up --verbose
agent-relay node status --wait-for 10
agent-relay node agent list
agent-relay node agent spawn claude --name Worker --task "Use https://agentrelay.com/skill and ACK over Relay."
agent-relay node tail --agent Worker
Expand Down
7 changes: 5 additions & 2 deletions .claude/skills/using-agent-relay/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,16 @@ remove_agent(name: "reviewer-1", reason: "Review accepted")

## Current CLI Reference

Startup and status commands are intentionally omitted from these agent-facing
examples. Published Agent Relay versions through 11.3.0 can print live
workspace credentials when those commands run in a transcribed session. Upgrade
to Agent Relay 11.3.1 or later before running them there.
Comment on lines +192 to +195

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Name the exact omitted commands.

The reference retains agent-relay status at Line 201. Therefore, “Startup and status commands are intentionally omitted” is inaccurate. Name the removed commands, such as agent-relay node up and agent-relay node status, so the safety boundary is clear.

Proposed wording
-Startup and status commands are intentionally omitted from these agent-facing
-examples.
+The `agent-relay node up` and `agent-relay node status` examples are
+intentionally omitted from these agent-facing examples.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Startup and status commands are intentionally omitted from these agent-facing
examples. Published Agent Relay versions through 11.3.0 can print live
workspace credentials when those commands run in a transcribed session. Upgrade
to Agent Relay 11.3.1 or later before running them there.
The `agent-relay node up` and `agent-relay node status` examples are
intentionally omitted from these agent-facing examples. Published Agent Relay
versions through 11.3.0 can print live
workspace credentials when those commands run in a transcribed session. Upgrade
to Agent Relay 11.3.1 or later before running them there.
🧰 Tools
🪛 SkillSpector (2.4.4)

[warning] 21: [AS3] Skill Enumeration: Skill enumerates or reads other installed skills. Access to other skills' SKILL.md files or the skills directory reveals prompt instructions, capabilities, and secrets that should be invisible to peer skills.

Remediation: Remove all code or instructions that list or read other skills' files or directories. Skills should operate independently; cross-skill access is a privilege escalation.

(Agent Snooping (AS3))


[warning] 54: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 75: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 90: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 92: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 93: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 94: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 95: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 98: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))


[warning] 227: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.

(Memory Poisoning (MP2))

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.claude/skills/using-agent-relay/SKILL.md around lines 192 - 195, Update the
introductory statement in the agent-facing examples to name the exact omitted
commands, including `agent-relay node up` and `agent-relay node status`, while
distinguishing them from the retained `agent-relay status` command. Preserve the
warning to upgrade to Agent Relay 11.3.1 or later before running the affected
commands in transcribed sessions.


These are the current CLI forms for local broker and SDK-backed messaging
operations:

```bash
agent-relay status
agent-relay node up --verbose
agent-relay node status --wait-for 10
agent-relay node agent list
agent-relay node agent spawn claude --name Worker --task "Use https://agentrelay.com/skill and ACK over Relay."
agent-relay node tail --agent Worker
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `agent-relay cloud whoami` prints the organization and workspace IDs alongside their names.

### Security

- Bundled Gemini and Codex relay instructions and hooks no longer expose workspace administration keys in observer URLs or terminal transcripts; observation now requires a separately provisioned, read-only observer token.

## [11.3.1] - 2026-07-31

### Fixed
Expand Down
64 changes: 64 additions & 0 deletions packages/cli/src/cli/plugin-credential-safety.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { readFileSync, readdirSync } from 'node:fs';
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';

const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../../..');

const agentFacingSkillFiles = [
'.agents/skills/using-agent-relay/SKILL.md',
'.claude/skills/using-agent-relay/SKILL.md',
] as const;

function readRepoFile(path: string): string {
return readFileSync(join(repoRoot, path), 'utf8');
}

function listPluginFiles(directory: string): string[] {
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
if (entry.name.startsWith('.') || entry.name === 'node_modules') return [];

const path = join(directory, entry.name);
return entry.isDirectory() ? listPluginFiles(path) : [path];
});
}

describe('shipped relay plugin credential safety', () => {
it('does not construct observer URLs from workspace keys in shipped plugin assets', () => {
const pluginFiles = listPluginFiles(join(repoRoot, 'plugins'));

for (const path of pluginFiles) {
const source = readFileSync(path, 'utf8');
expect(source, path).not.toMatch(/agentrelay\.com\/observer\?key=/i);
}
});

it('does not instruct agents to print real workspace keys or observer links', () => {
const pluginFiles = listPluginFiles(join(repoRoot, 'plugins'));

for (const path of pluginFiles) {
const source = readFileSync(path, 'utf8');
expect(source, path).not.toMatch(/\b(?:actual key|real clickable URL)\b/i);
expect(source, path).not.toMatch(/\bprint the observer URL\b/i);
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.

const credentialPrintLines = source
.split('\n')
.filter((line) => /\bprint\b/i.test(line) && /(?:workspace key|observer URL|ot_live_)/i.test(line));

for (const line of credentialPrintLines) {
expect(line, `${path}: ${line}`).toMatch(/\b(?:never|do not)\b[^\n]*\bprint\b/i);
}
}

const sessionStartHook = readRepoFile('plugins/gemini-relay-extension/hooks/session-start.sh');
expect(sessionStartHook).not.toMatch(/\bWORKSPACE_KEY\s*=/);
expect(sessionStartHook).not.toMatch(/\$\{?WORKSPACE_KEY\b/);
});

it('keeps credential-printing startup commands out of mirrored agent-facing skills', () => {
const [agentsSkill, claudeSkill] = agentFacingSkillFiles.map(readRepoFile);

expect(agentsSkill).toBe(claudeSkill);
expect(agentsSkill).not.toMatch(/\bagent-relay node (?:up|status)\b/);
});
});
7 changes: 6 additions & 1 deletion plugins/codex-relay-skill/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ Every relay-connected Codex agent must complete these steps IN ORDER before subs

2. **Register as an agent.** Call `register_agent` with your agent name and `type: "agent"`. Use `RELAY_AGENT_NAME` from the environment if set, otherwise derive a name from the task context (e.g., `lead`, `auth-worker`).

3. **Tell the user** they can follow the conversation live at `https://agentrelay.com/observer?key=<workspace_key>` (use the workspace key from step 1). This lets them watch all agent messages in real time.
3. **Keep workspace credentials out of output.** Never print the workspace key
or construct an observer URL from it. If the user asks to follow the
conversation, explain that observation requires a separately provisioned,
read-only observer token (`ot_live_...`) delivered through an explicit
secret handoff. Do not print the token or place it in a URL query string;
when no scoped observer token is available, omit the observer link.

4. **Check the relay inbox.** Call `check_inbox` to see if there are any pending messages or task assignments.

Expand Down
15 changes: 8 additions & 7 deletions plugins/gemini-relay-extension/GEMINI.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

This extension lets your Gemini CLI session communicate with other agents in real time via Agent Relay. A workspace is auto-created on first use — no configuration needed.

## Observer URL
## Safe observation

IMPORTANT: Before delegating any work to sub-agents, always print the observer URL so the user can watch the conversation in real time. Read the workspace key from the RELAY_API_KEY environment variable, or if empty read `~/.relay/workspace-key`, then print:
Never print a workspace key or construct an observer URL from one. Workspace
keys have administrative authority and do not belong in terminal transcripts
or URL query strings.

```
Follow along at: https://agentrelay.com/observer?key=<the actual key value>
```

Do not print a placeholder — print the real clickable URL with the actual key substituted in. This is mandatory every time you coordinate agents.
If the user asks to follow the conversation, explain that observation requires
a separately provisioned, read-only observer token (`ot_live_...`). The token
must be delivered through an explicit secret handoff, not printed by the agent.
When no scoped observer token has been provisioned, omit the observer link.

## Delegating to Sub-Agents

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ prompt = """Run a fan-out relay workflow for: {{args}}
Use fan-out only when the work can be split into independent subtasks.

Follow this protocol:
1. Read the workspace key from the RELAY_API_KEY environment variable, or if empty read ~/.relay/workspace-key. Print the observer URL so the user can follow along: https://agentrelay.com/observer?key=<the actual key>. This is mandatory.
1. Do not read or print the workspace key and do not construct an observer URL from it. If the user asks to follow along, explain that observation requires a separately provisioned, read-only observer token delivered through an explicit secret handoff. If none is available, omit the observer link.
2. Break the task into parallel subtasks with minimal overlap (max 5)
3. Delegate each subtask to a @relay-worker sub-agent. Give each a clear, bounded task description. Tell each worker your agent name so they can send ACK/DONE messages back to you via mcp_agent_relay_send_dm.
4. Monitor progress with mcp_agent_relay_check_inbox and answer worker questions
Expand Down
4 changes: 2 additions & 2 deletions plugins/gemini-relay-extension/commands/status/status.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
prompt = """Check the relay status:
1. Read the workspace key from the RELAY_API_KEY environment variable, or if empty read ~/.relay/workspace-key. Print the observer URL: https://agentrelay.com/observer?key=<the actual key>. Do not print a placeholder — print the real clickable URL.
1. Do not read or print the workspace key and do not construct an observer URL from it. Observation requires a separately provisioned, read-only observer token delivered through an explicit secret handoff. If none is available, omit the observer link.
2. Call mcp_agent_relay_list_agents to see who's online
3. Call mcp_agent_relay_check_inbox to see unread messages
4. Report a summary of the observer URL, agents, and any pending messages"""
4. Report a summary of the agents and any pending messages"""
2 changes: 1 addition & 1 deletion plugins/gemini-relay-extension/commands/team/team.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prompt = """Spawn a coordinated team of relay agents for: {{args}}

Follow this protocol:
1. Read the workspace key from the RELAY_API_KEY environment variable, or if empty read ~/.relay/workspace-key. Print the observer URL so the user can follow along: https://agentrelay.com/observer?key=<the actual key>. This is mandatory.
1. Do not read or print the workspace key and do not construct an observer URL from it. If the user asks to follow along, explain that observation requires a separately provisioned, read-only observer token delivered through an explicit secret handoff. If none is available, omit the observer link.
2. Analyze the task and choose the simplest coordination pattern that fits it
3. Determine how many workers are needed (max 5) and assign each a bounded responsibility
4. Choose the right sub-agent type for each task:
Expand Down
17 changes: 9 additions & 8 deletions plugins/gemini-relay-extension/hooks/session-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ load_env() {

load_env

# Resolve workspace key: env > persisted key file
WORKSPACE_KEY="${RELAY_API_KEY:-}"
if [ -z "$WORKSPACE_KEY" ] && [ -s "$KEY_FILE" ]; then
WORKSPACE_KEY=$(cat "$KEY_FILE" 2>/dev/null || true)
# Track whether Relay is configured without reading credential material into
# this hook. Workspace keys must never be placed in injected context.
WORKSPACE_CONFIGURED=0
if [ -n "${RELAY_API_KEY:-}" ] || [ -s "$KEY_FILE" ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: A whitespace-only persisted key file is reported as configured even though the relay server trims it to an empty key, so SessionStart can inject misleading registration/configuration guidance. Checking for non-whitespace content would keep this status aligned with the relay server without placing the key in context.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At plugins/gemini-relay-extension/hooks/session-start.sh, line 27:

<comment>A whitespace-only persisted key file is reported as configured even though the relay server trims it to an empty key, so SessionStart can inject misleading registration/configuration guidance. Checking for non-whitespace content would keep this status aligned with the relay server without placing the key in context.</comment>

<file context>
@@ -21,10 +21,11 @@ load_env() {
+# Track whether Relay is configured without reading credential material into
+# this hook. Workspace keys must never be placed in injected context.
+WORKSPACE_CONFIGURED=0
+if [ -n "${RELAY_API_KEY:-}" ] || [ -s "$KEY_FILE" ]; then
+  WORKSPACE_CONFIGURED=1
 fi
</file context>
Suggested change
if [ -n "${RELAY_API_KEY:-}" ] || [ -s "$KEY_FILE" ]; then
if [ -n "${RELAY_API_KEY:-}" ] || grep -q '[^[:space:]]' "$KEY_FILE" 2>/dev/null; then

WORKSPACE_CONFIGURED=1
fi

TOKEN=""
Expand All @@ -39,13 +40,13 @@ if [ -f "$STATE_FILE" ] && command -v jq >/dev/null 2>&1; then
fi

if [ -n "${TOKEN:-}" ] && [ -n "${AGENT_NAME:-}" ]; then
if [ -n "${WORKSPACE_KEY:-}" ]; then
CONTEXT=$(printf 'Relaycast is connected as %s. Use the Agent Relay MCP tools for DMs, channels, inbox checks, and worker coordination. Follow the ACK/DONE protocol: acknowledge new assignments promptly, and send DONE when the task is complete. To spawn workers, use run_shell_command with: RELAY_AGENT_NAME=WorkerName gemini -y -i "task prompt" &. The user can observe agent conversations at: https://agentrelay.com/observer?key=%s' "$AGENT_NAME" "$WORKSPACE_KEY")
if [ "$WORKSPACE_CONFIGURED" -eq 1 ]; then
CONTEXT=$(printf 'Relaycast is connected as %s. Use the Agent Relay MCP tools for DMs, channels, inbox checks, and worker coordination. Follow the ACK/DONE protocol: acknowledge new assignments promptly, and send DONE when the task is complete. To spawn workers, use run_shell_command with: RELAY_AGENT_NAME=WorkerName gemini -y -i "task prompt" &. Never print the workspace key or construct an observer URL from it. Observation requires a separately provisioned, read-only observer token delivered through an explicit secret handoff.' "$AGENT_NAME")
else
CONTEXT=$(printf 'Relaycast is connected as %s. Use the Agent Relay MCP tools for DMs, channels, inbox checks, and worker coordination. Follow the ACK/DONE protocol: acknowledge new assignments promptly, and send DONE when the task is complete. To spawn workers, use run_shell_command with: RELAY_AGENT_NAME=WorkerName gemini -y -i "task prompt" &.' "$AGENT_NAME")
fi
elif [ -n "${WORKSPACE_KEY:-}" ]; then
CONTEXT=$(printf 'Relaycast workspace key is configured. If the relay tools report "Not registered", call the register tool with your exact agent name before using messaging tools. The user can observe agent conversations at: https://agentrelay.com/observer?key=%s' "$WORKSPACE_KEY")
elif [ "$WORKSPACE_CONFIGURED" -eq 1 ]; then
CONTEXT='Relaycast workspace key is configured. If the relay tools report "Not registered", call the register tool with your exact agent name before using messaging tools. Never print the workspace key or construct an observer URL from it. Observation requires a separately provisioned, read-only observer token delivered through an explicit secret handoff.'
else
CONTEXT='Relaycast is connected. A workspace was auto-created. Use the Agent Relay MCP tools for messaging and worker coordination.'
fi
Expand Down
Loading