Cantrip.ACP.Diagnostics (Cantrip v1.3.3)

Copy Markdown View Source

Inspect live ACP sessions and bridges from a remsh attach during operations. Use this when you need to see what a running stdio ACP session is doing without restarting the host.

Live introspection helpers for a running ACP server.

Reach a running mix cantrip.familiar --acp BEAM via --remsh (the Mix task prints the exact command at startup), then call these functions from the IEx prompt to figure out what state the agent is in — useful when a session hangs.

iex> Cantrip.ACP.Diagnostics.dump()

Walks every AgentHandler ETS table (one per active connection) and prints what's there: session ids, bridge pids and their alive status, last_answer cache, the connection target. For each bridge that is alive, also reports its Process.info/1 (status, message_queue_len, current_function) so a hung bridge or a wedged mailbox is obvious.

No mutation. Safe to call any time.

Summary

Functions

Process.info/1 for one bridge, plus its mailbox length and current function — what you usually want when a bridge looks stuck.

Return a flat list of {session_id, bridge_pid} for every active bridge across all handler tables. Useful for piping into your own inspection: Cantrip.ACP.Diagnostics.bridges() |> Enum.map(...).

Walk the live ETS tables and print a structured summary of every ACP session, bridge, and connection. Returns the gathered data so it can be consumed programmatically too.

Like dump/0 but for one table ref. Used internally; exposed because remsh sometimes already has a table ref on hand. Accepts the same :redact option as dump/1.

Recursively replace secret-shaped values inside any term — maps, lists, tuples, and structs. Surfaced so test fixtures and ad-hoc inspection helpers can use the same scrubber.

Functions

bridge_info(pid)

Process.info/1 for one bridge, plus its mailbox length and current function — what you usually want when a bridge looks stuck.

bridges()

Return a flat list of {session_id, bridge_pid} for every active bridge across all handler tables. Useful for piping into your own inspection: Cantrip.ACP.Diagnostics.bridges() |> Enum.map(...).

dump(opts \\ [])

Walk the live ETS tables and print a structured summary of every ACP session, bridge, and connection. Returns the gathered data so it can be consumed programmatically too.

Options:

  • :redact — boolean, default true. When true, secret-shaped fields (api_key, _token, _secret, password, authorization, cookie) are replaced with "<redacted N chars>" in the returned data and in the printed output. Pass redact: false if you genuinely need to see them — but be aware that diagnostic dumps end up in pasted transcripts and bug reports.

dump_table(table, opts \\ [])

Like dump/0 but for one table ref. Used internally; exposed because remsh sometimes already has a table ref on hand. Accepts the same :redact option as dump/1.

redact(term)

Recursively replace secret-shaped values inside any term — maps, lists, tuples, and structs. Surfaced so test fixtures and ad-hoc inspection helpers can use the same scrubber.