How come in this run the dataset isnt mentioned or checked until i bring it up ? https://research.example.invalid/?view=assistant&sessionId=example-session-0009
Based on a real day; names and selected personal details have been changed or omitted.
How come in this run the dataset isnt mentioned or checked until i bring it up ? https://research.example.invalid/?view=assistant&sessionId=example-session-0009
I’ll trace how assistant sessions are loaded and how dataset context is supposed to enter the run. I’ll start from the repo docs and code paths for sessionId/assistant view, then compare that with any stored run/session payloads if they’re available locally or through the dashboard.
I found the main policy already says attached dataset context should be used first, so I’m checking whether this specific session actually had datasetId attached at the session/entry level and whether the planning prompt includes dataset profile content.
The likely weak point is narrower now: plan_remote_run accepts a datasetId, but the helper that writes the run prompt only uses chat history. The dataset profile helper exists, but isn’t currently called from that path. I’m checking the frontend next to see whether dataset context is sent at all from the linked session.
There are two concrete defects, not just model behavior: reopened assistant links send datasetId: null, and the backend only enriches the prompt from the request body, not the resolved session. Separately, the remote-run planner takes a dataset id but does not include dataset profile content in the planning prompt. I’m going to patch both so linked sessions keep their dataset context and planned runs are forced to see the dataset context before summarizing the task.
The backend patch is in place. I also need to update the run lifecycle docs because this changes the session-context contract, then I’ll run the standard validation and deploy flow required by the repo instructions.
pnpm build passes. I’m running the harness tests and dashboard QA next; if those pass I’ll run the Cloudflare dry-run deploy because this touched Worker request handling.
The standard checks passed. I’m running the Worker preview deploy check now, then I’ll commit and push per the repo instructions.
The Cloudflare dry-run succeeded. This repo has a real cf:deploy target, so I’m deploying the Worker now before staging only the files I changed.
Deployment completed successfully. I’m staging just src/worker.ts and docs/run-lifecycle.md; there are pre-existing unrelated edits in the worktree that I’m leaving alone.
The commit is created. I’m pushing the current branch now.
The cause was a backend context drop.
When that link reopened view=assistant&sessionId=..., the frontend did not send a datasetId unless the route also had datasetId. The backend resolved the existing session, but then only enriched the assistant prompt from the request body dataset id, so the stored session dataset was ignored. On top of that, plan_remote_run accepted a dataset id but built the remote-run prompt from chat history only, without injecting dataset profile/schema/sample context.
I fixed both in src/worker.ts: reopened dataset-linked sessions now fall back to the session’s stored datasetId, and remote-run planning now includes dataset context and explicitly requires checking mounted files/schema/samples/briefing. I also documented the contract in docs/run-lifecycle.md.
Validated:
pnpm build
pnpm test
pnpm run qa:dashboard
pnpm run cf:deploy:preview
pnpm run cf:deploy
Deployed Worker version: example-id-0034
Committed and pushed:
3b8ba29 Preserve dataset context in assistant sessions
There is still an unrelated pre-existing modified file left untouched: src/components/assistant-ui/thread.tsx.
::git-stage{cwd="/Users/example/Documents/Projects/alpha-research"} ::git-commit{cwd="/Users/example/Documents/Projects/alpha-research"} ::git-push{cwd="/Users/example/Documents/Projects/alpha-research" branch="codex/run-lifecycle-reconciliation"}
Dont add fallbacks or special cases. Think about it hollistically. What would make the most sense and be simple here for this context management.
Agreed. The clean model is: once a turn is bound to a session, the session is the context record. The request can update that record with a dataset, but prompt construction should read from the resolved session, not branch on route shape or keep one-off recovery wording. I’m simplifying the patch around that invariant.
The code now has a single context path: resolve session, read session.datasetId, build context from that. I removed the fallback language and catch-based prompt variant so failures surface as real request errors instead of silently degrading context.
Build passes with the simpler version. I’m running the remaining validations and deploy again because this changes the already-deployed Worker behavior.
The simplified Worker is deployed. I’m amending the previous commit so the branch history reflects the final context-management approach, then pushing it.
The amend landed on the current branch tip, which already had a frontend spacer commit in history. I’m checking the exact resulting commit contents now so I can correct the branch if that mixed scopes.
The scope did mix: the current top commit contains the existing spacer file plus my context changes. I’m going to split it back into two commits by moving the branch pointer back to the spacer commit while preserving the file changes, then committing only the context files on top.
You’re right. I simplified it to one rule:
The resolved assistant session is the context source of truth. If a request supplies datasetId, session resolution records it. After that, prompt construction reads resolvedSession.session.datasetId; no route-shape fallback, no catch-based context variant, no special “reopened session” wording.
Updated: src/worker.ts docs/run-lifecycle.md
I also corrected the commit history so the context change is a separate commit again:
1c410b7 Simplify assistant session dataset context
Validated and redeployed:
pnpm build
pnpm test
pnpm run qa:dashboard
pnpm run cf:deploy:preview
pnpm run cf:deploy
Deployed Worker version: example-id-0036
::git-stage{cwd="/Users/example/Documents/Projects/alpha-research"} ::git-commit{cwd="/Users/example/Documents/Projects/alpha-research"} ::git-push{cwd="/Users/example/Documents/Projects/alpha-research" branch="codex/run-lifecycle-reconciliation"}