Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export type {
// Output item types (StreamableOutputItem members)
OutputFileSearchCallItem,
OutputFunctionCallItem,
OutputImage,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocker] OutputInputImage removed from public re-exports without a backward-compat alias or changeset — this is a silent breaking change for consumers.

Details

Why: OutputInputImage was deliberately added as a public re-export in PR #20 so consumers could use it without a direct SDK dependency (CHANGELOG: "Re-export EasyInputMessageContentInputImage, OutputInputImage, and OpenAIResponsesToolChoiceUnion from the SDK models so consumers can use these types without a direct SDK dependency."). This PR removes it (replaced by OutputImage) with no backward-compat shim and no changeset. Any downstream package doing import type { OutputInputImage } from 'the agent package' now gets a compile error. The changeset initially added to this PR was removed in commit d1e4831 without justification.

Fix (preferred — zero version bump):

// packages/agent/src/index.ts
export type {
  OutputImage,
  OutputImage as OutputInputImage,  // backward-compat alias
  ...
}

Alternative: restore a changeset with a minor bump and document the removal as a breaking change.

Prompt for agents

In packages/agent/src/index.ts, add OutputImage as OutputInputImage to the re-export list alongside OutputImage to preserve the previously-announced public type alias, then verify bun run build and bun test pass.

Reviewed at c930772

OutputImageGenerationCallItem,
OutputInputImage,
OutputItems,
OutputMessage,
OutputReasoningItem,
Expand Down
20 changes: 16 additions & 4 deletions packages/agent/src/lib/model-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import {
isServerTool,
isToolCallOutputEvent,
} from './tool-types.js';
import { normalizeInputToArray } from './turn-context.js';

/**
* Typeguard for plain-object records (non-null, non-array).
Expand Down Expand Up @@ -231,6 +232,7 @@ export class ModelResult<
private approvedToolCalls: string[] = [];
private rejectedToolCalls: string[] = [];
private isResumingFromApproval = false;
private pendingFreshItems: models.BaseInputsUnion[] | undefined;

// Unified turn broadcaster for multi-turn streaming
private turnBroadcaster: ToolEventBroadcaster<
Expand Down Expand Up @@ -491,11 +493,18 @@ export class ModelResult<
response.output,
];

// Persist any fresh user input items that were collected during
// initStream, followed by the response output. Deferring the user-input
// persist to here (rather than before the API call) avoids duplicating
// user turns in state when a caller retries after an API failure.
let messages = this.currentState.messages;
if (this.pendingFreshItems && this.pendingFreshItems.length > 0) {
messages = appendToMessages(messages, this.pendingFreshItems);
this.pendingFreshItems = undefined;
}

await this.saveStateSafely({
messages: appendToMessages(
this.currentState.messages,
outputItems as models.BaseInputsUnion[],
),
messages: appendToMessages(messages, outputItems as models.BaseInputsUnion[]),
previousResponseId: response.id,
});
}
Expand Down Expand Up @@ -1527,6 +1536,8 @@ export class ModelResult<
? await this.applyHooksToFreshItems(freshItems, historicalMessages, initialContext)
: undefined;

this.pendingFreshItems = hookedFresh;

baseRequest = {
...baseRequest,
input: hookedFresh
Expand All @@ -1548,6 +1559,7 @@ export class ModelResult<
...baseRequest,
input: hookedInput,
};
this.pendingFreshItems = normalizeInputToArray(hookedInput) as models.BaseInputsUnion[];
}

// Store resolved request with stream mode
Expand Down
Loading
Loading