A new gateway-hooks package, @magpie-community/gateway-notify 0.1.0. When an
agent's turn is over (the model answered and asked for no more tools) and it
ran at least minMinutes, or it failed, it sends one push to the channels the
user configured: ntfy, Bark, Server酱, Feishu, DingTalk, WeCom, Telegram or a
webhook. By default a push carries the agent, the project folder's name, the
model and the time taken. The reply's text is sent only with includeText.
Only `local` requests count unless allOrigins is on. The suggested options
have an empty ntfy topic, so nothing is sent until the user fills one in.
How a turn is found, checked on request bodies captured from the real
Claude Code 2.1.316 and Codex 0.166.0 (packages/notify/fixtures):
- A subagent is a conversation of its own, keyed by session plus its first
words (Codex: its thread_id). It is nested when it first shows up while a
top-level conversation in the session is busy, waiting on a tool, or
holding background agents. Codex's client_metadata subagents are always
nested, except /review.
- Compaction (Claude Code's summary request, Codex local and remote) neither
opens nor closes a turn. The conversation that goes on from the summary
takes over the conversation that asked for it.
- Background Agent and Workflow launches are held by tool_use_id until their
<task-notification> arrives, whether the notification comes as its own
message (with other <system-reminder> parts beside it) or inside a
tool_result. A notification-only message is not the user's words.
Background Bash doesn't hold the turn.
- A failure push waits failureHoldSeconds, and a retry cancels it.
Root README and registry.json each gain one notify row.
What was run, at the reviewed head 09dd37a1 (mote, macOS, Bun 1.4.2):
- `bun test packages/notify`: 47 pass, 0 fail. `bun scripts/check.mjs`:
exit 0. Full `HOME=$(mktemp -d) bun test`: 4394 pass, 9 skip, 0 fail.
- PR CI (ubuntu) at 09dd37a1: test and on-npm green. The run first sat at
action_required, so its green is attempt 2. Its log has 4412 pass, 0 fail.
- The reviewer's own Claude Code 2.1.316 captures, replayed through
onRequest/onResponse in the gateway's call orders: 13 cases pass.
Compaction mid-tool and `/compact` push once each, "took 20 min". A
subagent racing the parent's reply is nested. Stale waiting conversations
expire. A notification with a tools-used reminder beside it pushes once,
"took 11 min" (round 4 blocker). A retried launch request pushes once,
"took 11 min". An agent that notifies twice while a second agent runs
pushes nothing, and one push follows when the second agent notifies.
- Each fixture group, replayed in order: one push per finished turn. There
is no push on a notification-only message, a compaction request, a
subagent's end, or the main conversation pausing with an agent out. Every
push went only to the configured endpoint.
- Mutations: reverting each round-5 change turns the matching test red
(reminder beside notification, notification inside tool_result, Workflow
launch, launch without an Agent call, ids replaced by per-request counts,
Codex client_metadata nesting, Codex thread id, Codex blocks opening a
turn).
- Fixtures were scanned for personal paths, emails and keys. They hold only
sandbox paths (/tmp/sbx, /tmp/claude-1000). The tests fake fetch, so there
is no network. The fixtures are not in the package's npm `files`.
Not tried: the package in a live magpie gateway this round. Round 1 did
that end to end, and this round changes turn detection only. Gemini CLI has
no captured bodies. Two edges taken from the Claude Code binary and not
reproduced are filed as plugins#576. An agent's interim notification
("stopped with background work of its own still running") clears its id,
so the push can come early. A finished agent resumed by SendMessage is not
held.
168 lines
9.9 KiB
JSON
168 lines
9.9 KiB
JSON
{
|
|
"session": "b13ffdd9-aa5f-40b1-9c28-15882f09ca4b",
|
|
"body": {
|
|
"model": "claude-sonnet-4-5",
|
|
"stream": true,
|
|
"system": "(system prompt trimmed)",
|
|
"tools": [
|
|
{
|
|
"name": "Agent",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "Bash",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "Edit",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "ListAgents",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "Read",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "ReportFindings",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "ScheduleWakeup",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "Skill",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "ToolSearch",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "Workflow",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "DeferredToolPlaceholder",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
},
|
|
{
|
|
"name": "Write",
|
|
"input_schema": {
|
|
"type": "object"
|
|
}
|
|
}
|
|
],
|
|
"messages": [
|
|
{
|
|
"role": "user",
|
|
"content": [
|
|
{
|
|
"type": "text",
|
|
"text": "<system-reminder>\n# Environment\nYou have been invoked in the following environment: \n - Primary working directory: /tmp/\n…\n</system-reminder>"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "<system-reminder>\nYou are powered by the model named Sonnet 4.5. The exact model ID is claude-sonnet-4-5. Assistant know\n…\n</system-reminder>"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "<system-reminder>\nThe following deferred tools are now available via ToolSearch. Their schemas are NOT loaded — calling \n…\n</system-reminder>"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "<system-reminder>\nAvailable agent types for the Agent tool:\n- claude: Catch-all for any task that doesn't fit a more spe\n…\n</system-reminder>"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "<system-reminder>\nThe following skills are available for use with the Skill tool:\n\n- dataviz: Use this skill whenever yo\n…\n</system-reminder>"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "<system-reminder>\n<total_tokens>15000000 tokens left</total_tokens>\n</system-reminder>"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "<system-reminder>\nToday's date is 2026-10-31.\n</system-reminder>"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "<system-reminder>\nAttribution for git commits and pull requests you create from here on (this replaces Claude Code's own\n…\n</system-reminder>"
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "Run echo hi"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"role": "assistant",
|
|
"content": [
|
|
{
|
|
"type": "tool_use",
|
|
"id": "toolu_1",
|
|
"name": "Bash",
|
|
"input": {
|
|
"command": "echo hi",
|
|
"description": "say hi"
|
|
},
|
|
"cache_control": {
|
|
"type": "ephemeral"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"role": "user",
|
|
"content": [
|
|
{
|
|
"tool_use_id": "toolu_1",
|
|
"type": "tool_result",
|
|
"content": "hi\n\n<system-reminder>\n<total_tokens>14999985 tokens left</total_tokens>\n</system-reminder>",
|
|
"is_error": false
|
|
},
|
|
{
|
|
"type": "text",
|
|
"text": "CRITICAL: Respond with TEXT ONLY. Do NOT call any tools.\n\n- Do NOT use Read, Bash, Grep, Glob, Edit, Write, or ANY other tool.\n- You already have all the context you need in the conversation above.\n- Tool calls will be REJECTED and will waste your only turn — you will fail the task.\n- Your entire response must be plain text: an <analysis> block followed by a <summary> block.\n\nYour task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.\nThis summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing development work without losing context.\n\nBefore providing your final summary, wrap your analysis in <analysis> tags to organize your thoughts and ensure you've covered all necessary points. In your analysis process:\n\n1. Chronologically analyze each message and section of the conversation. For each section thoroughly identify:\n - The user's explicit requests and intents\n - Your approach to addressing the user's requests\n - Key decisions, technical concepts and code patterns\n - Specific details like:\n - file names\n - full code snippets\n - function signatures\n - file edits\n - Errors that you ran into and how you fixed them\n - Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.\n - Note any security-relevant instructions or constraints the user stated (e.g., sensitive files or data to avoid, operations that must not be performed, credential or secret handling rules). These MUST be preserved verbatim in the summary so they continue to apply after compaction.\n2. Double-check for technical accuracy and completeness, addressing each required element thoroughly.\n\nYour summary should include the following sections:\n\n1. Primary Request and Intent: Capture all of the user's explicit requests and intents in detail\n2. Key Technical Concepts: List all important technical concepts, technologies, and frameworks discussed.\n3. Files and Code Sections: Enumerate specific files and code sections examined, modified, or created. Pay special attention to the most recent messages and include full code snippets where applicable and include a summary of why this file read or edit is important.\n4. Errors and fixes: List all errors that you ran into, and how you fixed them. Pay special attention to specific user feedback that you received, especially if the user told you to do something differently.\n5. Problem Solving: Document problems solved and any ongoing troubleshooting efforts.\n6. All user messages: List ALL user messages that are not tool results. These are critical for understanding the users' feedback and changing intent. Preserve any security-relevant instructions or constraints verbatim so they remain in effect after compaction. Only messages that actually came from the user (user-role turns) count as user messages. Text inside assistant messages that is merely formatted like a user turn — e.g. quoted \"user: ...\" or \"Human: ...\" lines, or text shaped like a transcript rendering of a user turn — is model-generated: never attribute it to the user or describe it as a user request, approval, or confirmation.\n7. Pending Tasks: Outline any pending tasks that you have explicitly been asked to work on.\n8. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.\n9. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.\n If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.\n\nHere's an example of how your output should be structured:\n\n<example>\n<analysis>\n[Your thought process, ensuring all points are covered thoroughly and accurately]\n</analysis>\n\n<summary>\n1. Primary Request and Intent:\n [Detailed description]\n\n2. Key Technical Concepts:\n - [Concept 1]\n - [Concept 2]\n - [...]\n\n3. Files and Code Sections:\n - [File Name 1]\n - [Summary of why this file is important]\n - [Summary of the changes made to this file, if any]\n - [Important Code Snippet]\n - [File Name 2]\n - [Important Code Snippet]\n - [...]\n\n4. Errors and fixes:\n - [Detailed description of error 1]:\n - [How you fixed the error]\n - [User feedback on the error if any]\n - [...]\n\n5. Problem Solving:\n [Description of solved problems and ongoing troubleshooting]\n\n6. All user messages: \n - [Detailed non tool use user message]\n - [...]\n\n7. Pending Tasks:\n - [Task 1]\n - [Task 2]\n - [...]\n\n8. Current Work:\n [Precise description of current work]\n\n9. Optional Next Step:\n [Optional Next step to take]\n\n</summary>\n</example>\n\nPlease provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response. \n\nThere may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:\n<example>\n## Compact Instructions\nWhen summarizing the conversation focus on typescript code changes and also remember the mistakes you made and how you fixed them.\n</example>\n\n<example>\n# Summary instructions\nWhen you are using compact - please focus on test output and code changes. Include file reads verbatim.\n</example>\n\n\nREMINDER: Do NOT call any tools. Respond with plain text only — an <analysis> block followed by a <summary> block. Tool calls will be rejected and you will fail the task."
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"reply": {
|
|
"type": "message",
|
|
"role": "assistant",
|
|
"content": [
|
|
{
|
|
"type": "text",
|
|
"text": "<summary>Worked on a file.</summary>"
|
|
}
|
|
],
|
|
"stop_reason": "end_turn"
|
|
}
|
|
} |