Skip to content

Pi adapter: hung ctx_execute cannot be aborted; Esc/Ctrl+C does nothing #959

Description

@Blue-B

I hit this with context-mode@1.0.169 on Pi interactive sessions.

On an investigate turn, the model called a large ctx_execute (recursive walk + log scan). The session stuck on Working... with no further toolResults. Esc did nothing, Ctrl+C did nothing, and the only recovery was force-killing Pi.

context-mode is actively steering into that path. On investigate turns it injects:

context-mode active. Hierarchy: ctx_batch_execute > ctx_execute > ctx_execute_file > ctx_search.

and after compaction it re-injects:

<session_mode>investigate</session_mode>

The hang itself is not just "model wrote a bad scan". Once ctx_execute is in flight, the Pi adapter cannot cancel it.

In build/adapters/pi/mcp-bridge.js, the registered tool execute path ignores the abort signal:

async execute(_toolCallId, params) {
  const result = await client.callTool(tool.name, params ?? {});
  // no `signal`
}

And tools/call is intentionally unbounded after #643:

return this.request(
  "tools/call",
  { name, arguments: args ?? {} },
  Number.POSITIVE_INFINITY,
);

So a hung or very long ctx_execute never times out, never receives Esc abort, and Pi never leaves Working.

What I expected:

  • Esc / Ctrl+C should cancel an in-flight tools/call and return a normal tool error
  • long jobs can still be allowed, but there needs to be either a default timeout with opt-out, or a hang watchdog that fails the tool and clears Working
  • investigate routing should not make an unrecoverable hang easy

The useful fix is not "ban ctx_execute". It is making the Pi adapter abortable and fail-safe. Something like:

async execute(_toolCallId, params, signal) {
  const result = await client.callTool(tool.name, params ?? {}, { signal });
  // reject pending request when signal aborts
}

plus either a finite default timeout for tools/call, or a watchdog that fails the tool after N idle seconds.

I am not saying context-mode caused the Cloudflare/provider error that started the session. The issue is that once the model follows the investigate/ctx_execute path and that call hangs, there is currently no recovery short of killing Pi.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions