refactor(session): nuke dead sessionParams / sessionDisplayId pipeline (v43)
These columns and the messages that plumbed them existed for the CLI-
adapter era — Gemini's resume id and provider-specific session params
rode the run-finished envelope back onto the session row so the next
turn could resume. Pi Mono dispatches every provider through pi-ai and
emits neither value. The worker has been posting literal null on every
finish, finalizeRun has been writing null into task_sessions, and
rotateSession has been carrying null forward.
Remove the wire, the writer, the carry-forward, and the columns:
- v43 migration rebuilds task_sessions without session_params_json /
session_display_id, and runs without session_display_id. Follows
the idempotent "create new, copy, swap, reindex" pattern used by
v41. context_snapshot_json is preserved (also unreferenced today
but outside this cleanup's scope).
- RunJob / EnqueueRunPayload / ChildMessage / worker-types zod
schema no longer carry the fields. finishRun() / createNewSession()
signatures tighten in lockstep.
- rotateSession starts the new session with fresh counters and no
carry-forward.
- turn-context resolveSession returns just the session id.
- TaskSessionRecord / RunRecord lose the dead fields.
498/498 unit tests pass. typecheck + build clean.
This commit is contained in:
1 parent
88a1f8b334
commit
e0e43d6127
32 files changed
+167
-205
No files matched your search
@@ -91,7 +91,6 @@ export function createRunDispatch(deps: OrchestrationDependencies) {
|
||||
exitCode: null,
|
||||
signal: null,
|
||||
model: null,
|
||||
sessionDisplayId: null,
|
||||
unattributedCost: true,
|
||||
});
|
||||
return;
|
||||
|
||||
@@ -196,7 +196,6 @@ export function createTaskRunner(
|
||||
exitCode: null,
|
||||
signal: null,
|
||||
model: null,
|
||||
sessionDisplayId: null,
|
||||
unattributedCost: true,
|
||||
});
|
||||
db.addActivity({
|
||||
|
||||
@@ -141,7 +141,6 @@ function resolveEnabledConnectorModels(
|
||||
function resolveSession(
|
||||
db: AppDatabase,
|
||||
agent: RunDispatchParams["agent"],
|
||||
task: RunDispatchParams["task"],
|
||||
companyId: string,
|
||||
connectorId: string,
|
||||
sessionHandoff: string | null,
|
||||
@@ -172,23 +171,8 @@ function resolveSession(
|
||||
}
|
||||
}
|
||||
|
||||
// `sessionParams` / `sessionDisplayId` are transient per-run state pi-ai
|
||||
// stamps onto the session row after a turn (e.g., Gemini's resume id).
|
||||
// They live on the agent session; read directly by session id.
|
||||
let sessionParams: Record<string, unknown> | null = null;
|
||||
let sessionDisplayId: string | null = null;
|
||||
const currentSession = db.getSessionById(currentSessionId);
|
||||
if (currentSession?.sessionParamsJson) {
|
||||
sessionParams = JSON.parse(currentSession.sessionParamsJson) as Record<string, unknown>;
|
||||
sessionDisplayId = currentSession.sessionDisplayId;
|
||||
}
|
||||
// Suppress the unused-parameter warning while keeping the signature
|
||||
// stable — task identity is reported through other fields on the
|
||||
// payload, not through the session row anymore.
|
||||
void task;
|
||||
|
||||
return {
|
||||
taskSession: { id: currentSessionId, sessionParams, sessionDisplayId },
|
||||
taskSessionId: currentSessionId,
|
||||
sessionHandoff: finalHandoff,
|
||||
};
|
||||
}
|
||||
@@ -292,7 +276,7 @@ export function buildRunPayload(params: RunDispatchParams, deps: TurnContextDeps
|
||||
const reviewTasks = db.listReviewTasksForManager(agent.id, companyId);
|
||||
const recentComments = assembleRecentComments(assignedTasks, reviewTasks, snapshot);
|
||||
const initialHandoff = resolveSessionHandoff(agent.id, deps);
|
||||
const { taskSession, sessionHandoff } = resolveSession(db, agent, task, companyId, connector.id, initialHandoff, deps);
|
||||
const { taskSessionId, sessionHandoff } = resolveSession(db, agent, companyId, connector.id, initialHandoff, deps);
|
||||
const skills = resolveSkills(companyId, agent.id, connector.id, agent.name, deps);
|
||||
|
||||
const systemPrompt = apiUrl ? buildTaskPrompt({
|
||||
@@ -363,10 +347,9 @@ export function buildRunPayload(params: RunDispatchParams, deps: TurnContextDeps
|
||||
model: modelSelection.effectiveModel,
|
||||
thinkingEffort,
|
||||
env,
|
||||
sessionParams: taskSession.sessionParams,
|
||||
systemPrompt,
|
||||
trigger,
|
||||
taskSessionId: taskSession.id ?? runId,
|
||||
taskSessionId: taskSessionId ?? runId,
|
||||
executionMode: db.getCompanyExecutionMode(companyId) as "ai_ceo" | "ai_cofounder",
|
||||
};
|
||||
}
|
||||
@@ -40,7 +40,6 @@ export interface EnqueueRunPayload {
|
||||
model: string | null;
|
||||
thinkingEffort: string | null;
|
||||
env: Record<string, string>;
|
||||
sessionParams: Record<string, unknown> | null;
|
||||
systemPrompt: string | null;
|
||||
trigger: string | null;
|
||||
/** Task session id used by SqliteSessionStore to load/append messages. */
|
||||
|
||||
Reference in new issue
Block a user