[PR #12870] fix: track session status for prompt_async and guard against missing agent #14411

Closed
opened 2026-02-16 18:19:12 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12870

State: closed
Merged: No


Summary

  • Set session status to busy immediately when prompt_async is called, so /session/status correctly reflects the active state instead of remaining unknown
  • Add .catch() handler on the fire-and-forget prompt promise to reset status to idle on failure and log the error, preventing the status from getting permanently stuck
  • Add a null check for the agent returned by Agent.get() in createUserMessage to prevent TypeError: undefined is not an object (evaluating 'agent.model') when an invalid agent name is provided

Test plan

  • Call POST /:sessionID/prompt_async and verify /session/status returns busy immediately
  • Verify status transitions to idle after the prompt completes
  • Trigger an error during async prompt (e.g. invalid agent) and verify status resets to idle
  • Send a prompt with a non-existent agent name and verify a clear error message instead of a TypeError

Fixes #12860

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12870 **State:** closed **Merged:** No --- ## Summary - Set session status to `busy` immediately when `prompt_async` is called, so `/session/status` correctly reflects the active state instead of remaining `unknown` - Add `.catch()` handler on the fire-and-forget prompt promise to reset status to `idle` on failure and log the error, preventing the status from getting permanently stuck - Add a null check for the agent returned by `Agent.get()` in `createUserMessage` to prevent `TypeError: undefined is not an object (evaluating 'agent.model')` when an invalid agent name is provided ## Test plan - [ ] Call `POST /:sessionID/prompt_async` and verify `/session/status` returns `busy` immediately - [ ] Verify status transitions to `idle` after the prompt completes - [ ] Trigger an error during async prompt (e.g. invalid agent) and verify status resets to `idle` - [ ] Send a prompt with a non-existent agent name and verify a clear error message instead of a TypeError Fixes #12860
yindo added the pull-request label 2026-02-16 18:19:12 -05:00
yindo closed this issue 2026-02-16 18:19:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14411