openclaw - 💡(How to fix) Fix ACP sessions spawned from hook-triggered agents lack session tracking and thread binding [8 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#54342Fetched 2026-04-08 01:28:43
View on GitHub
Comments
8
Participants
2
Timeline
8
Reactions
0
Timeline (top)
commented ×8

When a webhook-triggered agent (e.g., coder via /hooks/agent) spawns an ACP session with sessions_spawn(runtime: "acp"), two capabilities are missing:

Root Cause

When a webhook-triggered agent (e.g., coder via /hooks/agent) spawns an ACP session with sessions_spawn(runtime: "acp"), two capabilities are missing:

Fix Action

Fix / Workaround

Current workaround: sleep 60 + git fetch to check if commits appeared. Fragile, wastes time, can't detect ACP failures.

Current workaround: Don't use message tool; format the final response and let hook auto-delivery send it. This means no intermediate updates and only one message per webhook trigger.

RAW_BUFFERClick to expand / collapse

Context

When a webhook-triggered agent (e.g., coder via /hooks/agent) spawns an ACP session with sessions_spawn(runtime: "acp"), two capabilities are missing:

Problem 1: No session tracking for mode:"run"

process poll returns "No session found" for ACP mode: "run" sessions. The spawning agent has no way to know when the ACP session completes, what it produced, or if it failed.

Current workaround: sleep 60 + git fetch to check if commits appeared. Fragile, wastes time, can't detect ACP failures.

Desired: Either process poll works for ACP sessions (keyed by childSessionKey), or sessions_spawn supports a blocking/synchronous option that returns after the ACP session completes.

Problem 2: mode:"session" requires thread:true, unavailable in hook sessions

mode: "session" returns: mode="session" requires thread=true so the ACP session can stay bound to a thread.

But hook-triggered sessions (/hooks/agent) run without a channel context — there's no thread to bind to. thread: true returns: Thread bindings are unavailable for webchat.

This means hook-triggered agents can only use mode: "run" (fire-and-forget), losing:

  • Session persistence for resume
  • Ability to receive follow-up instructions
  • streamTo: "parent" progress streaming

Problem 3: Hook agents can't deliver to specific Telegram topics

The hook runner auto-delivers the agent's final response to hooks.mappings[].to. But if the agent needs to send additional messages (e.g., intermediate progress updates or structured reports) to a specific Telegram topic during execution, it needs the message tool. However, using message + hook auto-delivery causes duplicate messages (the auto-delivery sends the same content again).

There's no way to:

  • Suppress hook auto-delivery for a specific response
  • Send to a different target than the hook's configured to
  • Have the hook delivery go to a topic while the agent runs in a non-topic session

Current workaround: Don't use message tool; format the final response and let hook auto-delivery send it. This means no intermediate updates and only one message per webhook trigger.

Suggested Improvements

  1. process poll or session_status should track ACP sessions by childSessionKey
  2. Allow mode: "session" without thread: true — persist the session for later resumeSessionId use, even without thread binding
  3. Add hooks.mappings[].suppressAutoDelivery: true option so agents can use message tool without duplicates
  4. Or add hooks.mappings[].deliveryMode: "agent-controlled" where the agent handles its own delivery

Environment

  • OpenClaw 2026.3.13
  • acpx 0.1.16
  • Agent: coder, triggered via /hooks/agent from github-bridge
  • ACP harness: claude (Claude Code)

extent analysis

Fix Plan

To address the issues, we'll implement the following changes:

1. Session Tracking for ACP Sessions

Modify the sessions_spawn function to accept an optional blocking parameter. If blocking is true, the function will wait for the ACP session to complete before returning.

def sessions_spawn(runtime, blocking=False):
    # ... existing code ...
    if blocking:
        while True:
            session_status = session_status_api(childSessionKey)
            if session_status == "completed":
                return session_status
            time.sleep(1)
    # ... existing code ...

2. Allow mode: "session" without thread: true

Update the mode: "session" logic to persist the session without requiring a thread binding.

def sessions_spawn(runtime, mode, thread=False):
    # ... existing code ...
    if mode == "session" and not thread:
        # Persist the session without thread binding
        session_id = generate_session_id()
        save_session(session_id, runtime)
        return session_id
    # ... existing code ...

3. Suppress Hook Auto-Delivery

Add a suppressAutoDelivery option to the hooks.mappings configuration.

{
    "hooks": {
        "mappings": [
            {
                "to": "telegram-topic",
                "suppressAutoDelivery": true
            }
        ]
    }
}

Then, update the hook runner to respect this option.

def hook_runner(response):
    # ... existing code ...
    if response.get("suppressAutoDelivery"):
        # Do not auto-deliver the response
        return
    # ... existing code ...

Verification

To verify the fixes, test the following scenarios:

  • Spawn an ACP session with mode: "run" and verify that process poll returns the correct status.
  • Spawn an ACP session with mode: "session" and verify that the session is persisted without a thread binding.
  • Use the message tool with suppressAutoDelivery enabled and verify that no duplicate messages are sent.

Extra Tips

  • Ensure that the sessions_spawn function is properly handling errors and edge cases.
  • Consider adding additional logging and monitoring to track the status of ACP sessions and hook deliveries.
  • Review the documentation for the sessions_spawn function and hooks.mappings configuration to ensure that they are up-to-date and accurate.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix ACP sessions spawned from hook-triggered agents lack session tracking and thread binding [8 comments, 2 participants]