Skip to content

Commit 8a37459

Browse files
committed
fix: skip trajectories for ephemeral Crestodian plans
1 parent 8125b0a commit 8a37459

6 files changed

Lines changed: 27 additions & 16 deletions

File tree

‎src/agents/embedded-agent-runner/run.before-agent-reply-cron.test.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function firstBeforeAgentReplyCall() {
2525

2626
function firstAttemptParams(): {
2727
cleanupBundleMcpOnRunEnd?: boolean;
28+
disableTrajectory?: boolean;
2829
modelRun?: boolean;
2930
promptMode?: string;
3031
promptCacheKey?: string;
@@ -34,6 +35,7 @@ function firstAttemptParams(): {
3435
| [
3536
{
3637
cleanupBundleMcpOnRunEnd?: boolean;
38+
disableTrajectory?: boolean;
3739
modelRun?: boolean;
3840
promptMode?: string;
3941
promptCacheKey?: string;
@@ -153,19 +155,21 @@ describe("runEmbeddedAgent cron before_agent_reply seam", () => {
153155
expect(mockedRunEmbeddedAttempt).toHaveBeenCalledTimes(1);
154156
});
155157

156-
it("forwards one-shot model-run flags into the embedded attempt", async () => {
157-
// Model-run mode is request-scoped; it must pass through to the first
158-
// attempt without becoming a persistent session setting.
158+
it("forwards one-shot auxiliary-run flags into the embedded attempt", async () => {
159+
// Auxiliary-run flags are request-scoped; they must pass through to the
160+
// first attempt without becoming persistent session settings.
159161
mockedRunEmbeddedAttempt.mockResolvedValueOnce(makeAttemptResult({ promptError: null }));
160162

161163
await runEmbeddedAgent({
162164
...overflowBaseRunParams,
163165
trigger: "user",
166+
disableTrajectory: true,
164167
modelRun: true,
165168
promptMode: "none",
166169
});
167170

168171
const attemptParams = firstAttemptParams();
172+
expect(attemptParams.disableTrajectory).toBe(true);
169173
expect(attemptParams.modelRun).toBe(true);
170174
expect(attemptParams.promptMode).toBe("none");
171175
});

‎src/agents/embedded-agent-runner/run.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2556,7 +2556,7 @@ async function runEmbeddedAgentInternal(
25562556
runtimePlan,
25572557
});
25582558
const hostTrajectoryRecorder =
2559-
agentHarness.id === CODEX_HARNESS_ID
2559+
agentHarness.id === CODEX_HARNESS_ID && !params.disableTrajectory
25602560
? createTrajectoryRuntimeRecorder({
25612561
cfg: params.config,
25622562
env: process.env,
@@ -2813,6 +2813,7 @@ async function runEmbeddedAgentInternal(
28132813
inputProvenance: params.inputProvenance,
28142814
streamParams: params.streamParams,
28152815
modelRun: params.modelRun,
2816+
disableTrajectory: params.disableTrajectory,
28162817
promptMode: params.promptMode,
28172818
ownerNumbers: params.ownerNumbers,
28182819
enforceFinalTag: params.enforceFinalTag,

‎src/agents/embedded-agent-runner/run/attempt.ts‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,18 +3212,20 @@ export async function runEmbeddedAttempt(
32123212
sessionKey: params.sessionKey,
32133213
sessionTarget: params.sessionTarget,
32143214
});
3215-
trajectoryRecorder = createTrajectoryRuntimeRecorder({
3216-
cfg: params.config,
3217-
env: process.env,
3218-
runId: params.runId,
3219-
sessionId: activeSession.sessionId,
3220-
sessionKey: params.sessionKey,
3221-
sessionFile: trajectorySessionFile,
3222-
provider: params.provider,
3223-
modelId: params.modelId,
3224-
modelApi: params.model.api,
3225-
workspaceDir: params.workspaceDir,
3226-
});
3215+
trajectoryRecorder = params.disableTrajectory
3216+
? null
3217+
: createTrajectoryRuntimeRecorder({
3218+
cfg: params.config,
3219+
env: process.env,
3220+
runId: params.runId,
3221+
sessionId: activeSession.sessionId,
3222+
sessionKey: params.sessionKey,
3223+
sessionFile: trajectorySessionFile,
3224+
provider: params.provider,
3225+
modelId: params.modelId,
3226+
modelApi: params.model.api,
3227+
workspaceDir: params.workspaceDir,
3228+
});
32273229
trajectoryRecorder?.recordEvent("session.started", {
32283230
trigger: params.trigger,
32293231
sessionFile: params.sessionFile,

‎src/agents/embedded-agent-runner/run/params.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ export type RunEmbeddedAgentParams = {
135135
forceRestartSafeTools?: boolean;
136136
/** Internal one-shot model probe mode: no tools, no workspace/chat prompt policy. */
137137
modelRun?: boolean;
138+
/** Disable trajectory persistence for auxiliary runs with no durable session owner. */
139+
disableTrajectory?: boolean;
138140
/** Explicit system prompt mode override for trusted callers. */
139141
promptMode?: PromptMode;
140142
/** Keep the message tool available even when a narrow profile would omit it. */

‎src/crestodian/assistant.configured.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ describe("Crestodian configured-model planner", () => {
327327
}),
328328
);
329329
expect(runEmbeddedAgent.mock.calls[0]?.[0]?.sessionKey).toBeUndefined();
330+
expect(runEmbeddedAgent.mock.calls[0]?.[0]?.disableTrajectory).toBe(true);
330331
});
331332

332333
it("carries the verified child runtime artifact into planning", async () => {

‎src/crestodian/assistant.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export async function planCrestodianCommandWithConfiguredModel(params: {
109109
messageChannel: "crestodian",
110110
messageProvider: "crestodian",
111111
disableTools: true,
112+
disableTrajectory: true,
112113
...(route.authProfileId ? { authProfileId: route.authProfileId } : {}),
113114
};
114115
const result =

0 commit comments

Comments
 (0)