Skip to content

fix(chat): send the first new-session message after a slash command - #161

Closed
Broglah1 wants to merge 1 commit into
ompweb-dev:mainfrom
Broglah1:fix/new-session-slash-404
Closed

Broglah1 wants to merge 1 commit into
ompweb-dev:mainfrom
Broglah1:fix/new-session-slash-404

Conversation

@Broglah1

Copy link
Copy Markdown
Contributor

Fixes #160

Summary

  • in a new session, typing / loads slash commands through ensure_session, which spawns the omp session before its first prompt. omp writes the session .jsonl only once the first message is committed, so on Send the pre-dispatch boundary read (GET /api/sessions/<id>/context?boundary=1) found no file, returned 404 session_not_found, and snapshotRunEntries aborted the send with Failed to send message: HTTP 404. Every slash command in a new session hit this (/pbr, /new, skills, prompt templates).
  • the context route now returns { entryIds: [] } for boundary=1 when the session's wrapper is live and idle and its file does not exist yet: it has persisted nothing, so its boundary is empty. This mirrors the existing sync=1 handling of a live wrapper without a file.
  • an in-flight unpersisted run still returns 404 (the existing boundary never substitutes unpersisted live output guard is unchanged), so that run's entries are never attributed to the next prompt. A missing file without a live wrapper is still 404.

Validation

  • new test in lib/session-routes.test.mjs: idle live wrapper without a file → 200 { entryIds: [] }; after agent_start → 404; wrapper removed → 404. Fails without the fix (actual: 404, expected: 200), passes with it.
  • npm run typecheck, npm run lint (0 errors; changed files clean), npm test: 905 pass / 0 fail (1 skipped)
  • browser smoke (Chromium, dev server on this branch, web v0.5.1): New Session → workspace → type /new → Send. Typing / spawns the session (POST /api/agent/new 200); Send now issues context?boundary=1 → 200 and the prompt → 200, with no error notice. The same steps on published 0.5.1 fail with HTTP 404.
  • npm run build not run locally (dev-tree rule in AGENTS.md); CI covers it.

Typing "/" loads slash commands through ensure_session, which spawns the
omp session before its first prompt. omp writes the session file only
once the first message is committed, so the pre-dispatch boundary read
(context?boundary=1) returned 404 and the send failed with "HTTP 404".

Return an empty boundary for a live, idle wrapper whose file does not
exist yet. An in-flight unpersisted run still returns 404, so its entries
are never attributed to the next prompt.

Fixes ompweb-dev#160

@Broglah1 Broglah1 left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#165 fixes the same bug (#160) in the same place, app/api/sessions/[id]/context/route.ts, and is the better of the two fixes.

The two differ only while a new session's first reply is still running and not yet saved. This PR still returns 404 for context?boundary=1 then; #165 returns { entryIds: [] }. #165 matches how sessions that already have a file behave mid-run (the boundary lists what has been saved), so the extra 404 here would only make interrupt-and-reply fail during a new session's first reply.

Checked locally on both branches (Windows 11, omp 18.4.2):

  • The #160 flow (new session, type /new, Send) works on both.
  • A boundary request during an unsaved first reply returns 404 here and 200 { entryIds: [] } on #165.
  • Each PR's route test fails on the other PR's route only at that mid-run assertion.

@Broglah1

Copy link
Copy Markdown
Contributor Author

Closing in favour of #165, which fixes the same bug. See the review above for the comparison.

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.

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

1 participant