Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/lib/tools/BetaToolRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,17 @@ export class BetaToolRunner<Stream extends boolean> {
const isCompacted = await this.#checkAndCompact();
if (!isCompacted) {
if (!this.#mutated) {
const { role, content } = await this.#message;
const message = await this.#message;
const { role, content } = message;
this.#state.params.messages.push({ role, content });

// Propagate container.id for code_execution tool reuse.
// Without this, the next iteration fails with:
// "container_id is required when there are pending tool uses
// generated by code execution with tools."
if (message.container?.id) {
this.#state.params.container = message.container.id;
}
}

const toolMessage = await this.#generateToolResponse(this.#state.params.messages.at(-1)!);
Expand Down