Skip to content

[Bug] First message in a new session fails with "HTTP 404" after typing a slash command #160

Closed

Description

@Broglah1

Describe the bug
In a new session, the first message fails with Failed to send message: HTTP 404 whenever the composer's slash-command list was opened first — typing / for any command (/pbr, /new, skills, prompt templates). The optimistic bubble is rolled back and nothing reaches omp.

Cause: typing / loads slash commands, which calls ensureNewSession() and spawns the omp session (ensure_session) before any prompt. omp does not create the session .jsonl until the first message is committed. On Send, handleSend sees the existing session id and reads the run boundary (GET /api/sessions/<id>/context?boundary=1) before dispatching. That route only resolves session files, so it returns 404 session_not_found; snapshotRunEntries throws HTTP 404 and the send aborts. The sync=1 branch of the same route already treats a live wrapper without a file as empty history — boundary=1 has no equivalent.

To reproduce

  1. Click New Session and pick a workspace.
  2. Type a slash command in the composer (e.g. /pbr or /new).
  3. Press Send.
  4. Notice: Failed to send message: HTTP 404.

Same thing at the API level:

POST /api/agent/new  {"cwd": "<dir>", "type": "ensure_session"}   -> 200 {"sessionId": "<id>"}
GET  /api/sessions/<id>/context?boundary=1                         -> 404 {"code": "session_not_found"}
GET  /api/agent/<id>                                                -> 200 {"running": true, ...}

Expected behavior
The first message is sent. A live, idle session that has not persisted its file yet has no prior entries, so its run boundary is empty.

Screenshots
N/A — the error is the composer notice above.

Environment

  • OS: Windows 11 (10.0.26200)
  • Node.js version: v24.19.0
  • omp version: 18.4.2
  • Browser: Chromium (server-side route; browser-independent)
  • omp-web version: 0.5.1 (npx @kahme247/ompweb@latest); code path unchanged on main at e822c7f

Additional context
Surfaced by the pre-dispatch boundary snapshot (snapshotRunEntries, #94/#95). The existing guard boundary never substitutes unpersisted live output covers an in-flight run and should stay: that run's unpersisted entries must not be attributed to the next prompt. Only the idle, never-run case needs an empty boundary. A fix PR follows.

Activity

  1. kahme247 commented on Oct 2, 2026

    @kahme247
    Collaborator

    This is already fixed on main.

    Root cause: the first message of a new session was sent before omp had written its transcript to disk, so the boundary request GET /api/sessions/:id/context?boundary=1 404'd on the missing session file and the send was refused.

    Fix: �pp/api/sessions/[id]/context/route.ts now returns an empty �ntryIds for a live session whose file has not been written yet, instead of 404-ing, and the client sends the prompt anyway.

    Relevant commits:

    • \�a617860\ fix(chat): do not 404 sends to a live session before its first reply is saved
    • \2152c67e\ fix(agent-session): send prompts to sessions with no on-disk transcript yet
    • \�6ebcc7e\ test(agent-session): cover the boundary-404 send paths

    Regression coverage in \hooks/useAgentSession.rpc.test.mjs: send tolerates a missing session file (local-only slash commands) and still dispatches, REVIEW #165: a fileless LIVE session already gets an empty boundary, so main dispatches, and REVIEW a 404 boundary on a live session (unreadable file / wrapper died) still dispatches — all passing.

    Closing as fixed. If you still see the 404, please reopen with the session id and the exact request from the devtools Network tab.

  2. kahme247 commented on Oct 2, 2026

    @kahme247
    Collaborator

    Verified fixed on main (see the comment above with commit refs and passing regression tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions