Skip to content

fix: pi.sendUserMessage/sendMessage return Promise#5752

Closed
steptian wants to merge 1 commit into
earendil-works:mainfrom
steptian:fix/send-user-message-return-promise
Closed

fix: pi.sendUserMessage/sendMessage return Promise#5752
steptian wants to merge 1 commit into
earendil-works:mainfrom
steptian:fix/send-user-message-return-promise

Conversation

@steptian

Copy link
Copy Markdown

Problem

pi.sendUserMessage() and pi.sendMessage() in the extension API do not return their underlying Promise. This means await pi.sendUserMessage(...) resolves immediately (after ~1ms) instead of waiting for the agent to finish.

Impact

In print mode (pi -p), extensions that call pi.sendUserMessage() in session_start hooks cause a race condition where print-mode's session.prompt() sees isStreaming === true and throws:

Agent is already processing. Specify streamingBehavior...

This breaks subagent calls and any print-mode usage.

Fix

Two missing return statements:

  1. packages/coding-agent/src/core/extensions/loader.ts:
    sendMessage() and sendUserMessage() delegate to runtime but don't return the Promise.

  2. packages/coding-agent/src/core/agent-session.ts:
    The runtime sendUserMessage binding also drops the Promise.

Closes #5751

Both sendMessage() and sendUserMessage() in createExtensionAPI()
and the runtime sendUserMessage binding did not return their
underlying Promise. This caused extensions' await calls to
resolve immediately (~1ms), leaving the agent in streaming
state when print-mode's session.prompt() was called next.

Fixes: earendil-works#5751
@github-actions

Copy link
Copy Markdown
Contributor

This PR was auto-closed. Only contributors approved with lgtm can open PRs. Open an issue first.

Maintainers review auto-closed issues daily. Issues that do not meet the quality bar in CONTRIBUTING.md will not be reopened or receive a reply.

If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

See CONTRIBUTING.md.

@github-actions github-actions Bot closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pi.sendUserMessage() and pi.sendMessage() don't return Promise, causing fire-and-forget in print mode

1 participant