Repository navigation
Conversation
Co-authored-by: AI (Pi/Claude Opus 5.5) <noreply@pi.dev>
jfinnson
marked this pull request as ready for review
December 5, 2026 01:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a request/response way to start a session and read Prime's reply, for clients that cannot hold a Socket.IO connection (for example a browser page that reaches the Shell through a buffered HTTP proxy).
POST /api/session-launcheswith{ bundleId, prompt }promptinto Prime's primary conversation through the same path aschat:message.restrictedfrom the moment it is created, so no other user canchat:joinit before the caller's access settings apply.201 { sessionId, conversationId, turnId, sessionUrl }.turnIdis the prompt's Message id.sessionUrlusesTANGENT_PUBLIC_URLwhen set, otherwise the request origin.409and the session is cleaned up.GET /api/sessions/:id/turns/:turnId?wait=N{ status, done, reply, error }, wherestatusisrunning,completed(with Prime's reply) orfailed(witherror).waitis an integer from 0 to 25 seconds (default 0) and holds the request until the turn settles. 25 seconds keeps a long poll under common 30–60 second proxy timeouts.chat:join:401without identity,403when the caller cannot read Prime's thread,404for an unknown, expired, or other-session turn. A poll whose client disconnects during authorization is released.How a reply is attributed to the turn
TurnTracker(apps/server/src/conversation/turnTracker.ts) follows the exact launch Message id from delivery (DeliveryRequest.messageId) to the Pi prompt and listens forPiAgentManager's placement of that prompt (usePromptPlacement):startedorqueuedanswer confirms the Run; only output after confirmation can become the reply.handled, a rejection, a missing disposition, a cleared queue, or the process dying before it answers fails the turn.reply: nullwhen its prompt is queued behind other work, when any other prompt reaches the same Prime while the turn is pending, or when its Run is superseded. An exact resend of the launch's own Message id is not a competitor. The underlying Run and UI carry on unchanged; only the HTTP turn settles.When the tracker cannot tell whose answer it is, it fails the turn rather than return another prompt's reply.
Other changes
Promise.allSettled), so a failed database delete no longer skips agent disposal.packages/shared/src/contracts.ts, and a "Launching a session over HTTP" section indocs/server/index.md.Screenshots
N/A — server API and documentation only.
How to test
Prerequisites: pnpm 10.28.0 (
packageManager).pnpm install --frozen-lockfilepnpm --filter @tangent/server test— 972/972 pass on this branch (rebased onmainat78d3283).pnpm validate— 33/33 tasks pass; lint reports 0 errors and 5 existingmax-lines-per-functionwarnings in files this change does not add.apps/server/src/routes/sessionLaunches.test.ts,apps/server/src/conversation/turnTracker.test.ts,apps/server/src/conversation/turnTracker.pi.test.ts, and the placement cases inapps/server/src/pi/piAgentManager.test.ts.401; another user on the restricted session →403; unknown or cross-session turn →404;wait=26orwait=abc→400;wait=0returns at once.Notes
FakeChildtests, not a live Pi 1.6 process, so a check on the deployed image is still needed.404for every turn (the session and transcript remain). With several replicas, polls must reach the process that created the turn.409.EMBED_ALLOWED_ORIGINSand by its sign-in provider; that configuration is outside this change.