Skip to content

Commit dfdbaaf

Browse files
committed
fix(runtime): preserve graph input provenance
Generated-by: Codex
1 parent b572e61 commit dfdbaaf

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

packages/runtime/src/graph-mode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function renderGraphModePrompt(): string {
1515
'Stay available to the user across supervisor turns. Intervene only through the typed graph controls, and explain material supervision decisions.',
1616
'Before advancing dependencies or finishing, read the committed child result with agent_output like {"locator":"child_session_run","child_session_id":"<childSessionId>","run_id":"<currentRunId>","view":"result","max_bytes":32768}. Use result.resultRecordId when selecting a final committed record. Read runtime_events or view=all only for a narrow diagnostic question. Then select committed result ids with update_agent_graph.finish and synthesize those results for the user.',
1717
'When scheduling dependent work, pass each upstream result.resultRecordId in input_ids. The Runtime resolves those references into bounded, source-linked operator handoffs, so do not manually restate the child conclusion in the next instruction.',
18+
'For a result selected by a finished earlier graph epoch, use selected_result_inputs with the exact source_graph_id and result_id returned by view_agent_graph. Keep input_ids for records in the current graph; historical inputs carry data lineage only and never reuse old operators or control state.',
1819
'You may continue directly when the request is small or a graph would add ceremony without useful decomposition.',
1920
'</orchestration_mode>',
2021
].join('\n');

packages/runtime/src/stream-graph-coordinator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ export class AgentGraphCoordinator {
12311231
}
12321232
const page = await this.#input.epochStore.listAgentGraphEpochPage({
12331233
rootSessionId,
1234-
beforeEpoch: beforeEpoch ?? current.epoch,
1234+
beforeEpoch: Math.min(beforeEpoch ?? current.epoch, current.epoch),
12351235
limit: 1,
12361236
});
12371237
const selected: AgentGraphSelectedResultInput[] = [];

packages/runtime/src/stream-graph-schedule-reconcile.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ export async function reconcileAgentGraphSchedule(
197197
snapshot.observation.projection.records.map((record) => [record.recordId, record]),
198198
);
199199
for (const [recordId, record] of snapshot.selectedResultRecords) {
200+
if (committedRecords.has(recordId)) {
201+
throw new Error(`Selected graph result id ${recordId} collides with the current graph`);
202+
}
200203
committedRecords.set(recordId, record);
201204
}
202205
const deferredWork: AgentGraphScheduleDeferredWork[] = [];

0 commit comments

Comments
 (0)