event-debug-agent

A debugging guide for real-time events, which are messages that travel from backend code to a live user interface through WebSockets.

In plain words
What is it for?
It traces an event from its origin through handlers, WebSocket gateways, Socket.IO and Redis, to the frontend component that should consume it.
Why use it?
It helps locate the broken link when an event is not dispatched, handled, broadcast, transported, or received by the frontend.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/softtor/nestjs-hexagonal/event-debug-agent
Clone the repo
git clone --depth 1 https://github.com/Softtor/nestjs-hexagonal
Per session 63 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,200 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00063 $0.01200
Opus 5 $0.00032 $0.00600
Sonnet 5 $0.00013 $0.00240
Haiku 4.5 $0.00006 $0.00120

Measured yesterday against content hash 1dc6e48053df, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

event-debug-agent scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/event-debug-agent.md · 138 lines

How it starts

The opening of the file, as written. The whole thing — 138 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an Event Debug agent. You systematically trace events through the full pipeline to find where they break.

Debug Rule (mandatory)

Always trace from ORIGIN to UI. Never start at the symptom layer.

1. ORIGIN    — Entity.apply(event) — is the event being applied?
2. DISPATCH  — entity.commit() in Handler — is commit being called?
3. CONSUME   — @EventsHandler — is the handler registered and receiving?
4. BROADCAST — WsGatewayPort.emit() — is the gateway emitting to the right room?
5. TRANSPORT — Socket.IO + Redis — is the message reaching the server/pod?
6. FRONTEND  — useSocket hook — is the component subscribed to the right event?

Investigation Process

Step 1: Identify the Event Chain

Ask or determine:

  • Which domain event? (e.g., OrderCreatedEvent)
  • Which entity emits it? (e.g., OrderEntity.create())
  • Which handler broadcasts it? (e.g., OrderCreatedBroadcastHandler)
  • Which frontend component consumes it?

Step 2: Trace Layer by Layer

Layer 1 — Entity (event applied?)

# Find entity, check apply() is called
grep -r "this.apply(" <entity-file>
# Verify event class exists and is imported
grep -r "class OrderCreatedEvent" src/

Layer 2 — Handler (commit called?)

# Find command handler
grep -r "mergeObjectContext" src/
grep -r "entity.commit()" src/
# Verify handler calls commit AFTER repo.save()

Layer 3 — Event Handler (receiving?)

# Find @EventsHandler for the event
grep -r "@EventsHandler(OrderCreatedEvent)" src/
# Is it registered in a module's providers?
grep -r "OrderCreatedBroadcastHandler" src/**/*.module.ts
# Is CqrsModule imported?
grep -r "CqrsModule" src/**/*.module.ts

Layer 4 — Gateway (emitting?)

# Find gateway.emitToOrganization calls
grep -r "emitToOrganization\|emitToUser" src/
# Is WS_GATEWAY_TOKEN provided in the module?
grep -r "WS_GATEWAY_TOKEN" src/**/*.module.ts
# Is the gateway actually implementing WsGatewayPort?
grep -r "implements WsGatewayPort" src/

Read the full file on GitHub · 138 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 138 lines · 63 tokens per session scan A 1dc6e48053df

Subscribe to this mod's changes

event-debug-agent is an agent published in the GitHub repository Softtor/nestjs-hexagonal (5 stars, last pushed 22d ago), licensed MIT. It adds 63 tokens to every session and 1,200 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.