Skip to content

relay agent remove fails for agents with message history, leaks raw SQL #1399

Description

@khaliqgant

relay agent remove fails for any agent that has sent a message, and surfaces a raw SQL statement as the error.

Reproduce

relay agent register probe-a          # capture token
RELAY_AGENT_TOKEN=$TOK relay channel create probe-ch
RELAY_AGENT_TOKEN=$TOK relay message post probe-ch 'hello'
relay agent remove probe-a

Output:

Failed query: delete from "agents" where "agents"."id" = ?
params: 208579108764696576

Exit code is 1 (correct), and the agent is still listed afterwards. An agent that has not sent anything deletes fine — in a two-agent test the receiver was removed and the sender was not, every time.

Two problems

  1. The delete is blocked, almost certainly by a foreign key from messages/DMs/read receipts onto agents. Either cascade, soft-delete, or refuse with a real explanation.
  2. The error leaks internal SQL. Failed query: delete from "agents" where "agents"."id" = ? plus a raw row id is not an actionable user-facing message, and it exposes schema detail.

Impact

Every verification run leaves undeletable test identities behind. 16 accumulated in the Default workspace during this work and cannot be cleaned up through the CLI. Any workflow that registers disposable agents will grow the roster permanently.

packages/cli/src/cli/commands/agent.ts just calls relay.agents.delete(name), so the fix is server-side.

Related

workflows/verify-features.ts now asserts the agent is actually gone after agent remove, rather than assuming a reported success meant it worked.


Found by workflows/verify-features.ts during a live end-to-end run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfactory-readyApproved for the Factory to pick up and implement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions