Skip to content
Merged
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
13 changes: 11 additions & 2 deletions packages/runner/src/builtins/llm-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import { ID, NAME, type Recipe, TYPE } from "../builder/types.ts";
import type { Action } from "../scheduler.ts";
import type { IRuntime } from "../runtime.ts";
import type { IExtendedStorageTransaction } from "../storage/interface.ts";
import {
debugTransactionWrites,
formatTransactionSummary,
} from "../storage/transaction-summary.ts";
import { parseLink } from "../link-utils.ts";
// Avoid importing from @commontools/charm to prevent circular deps in tests

Expand Down Expand Up @@ -811,8 +815,13 @@ async function invokeToolCall(
...toolCall.input,
result, // doesn't HAVE to be used, but can be
}, (completedTx: IExtendedStorageTransaction) => {
resolve(result.withTx(completedTx).get()); // withTx likely superfluous
}); // TODO(bf): why any needed?
logger.info("Handler tx:", debugTransactionWrites(completedTx));

const summary = formatTransactionSummary(completedTx, space);
const value = result.withTx(completedTx).get();

resolve({ value, summary });
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 30, 2025

Choose a reason for hiding this comment

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

Handler tool results are now double-wrapped, so LLM/tool consumers receive { value: { value, summary } } instead of the handler output.

Prompt for AI agents
Address the following comment on packages/runner/src/builtins/llm-dialog.ts at line 823:

<comment>Handler tool results are now double-wrapped, so LLM/tool consumers receive `{ value: { value, summary } }` instead of the handler output.</comment>

<file context>
@@ -811,8 +815,13 @@ async function invokeToolCall(
+        const summary = formatTransactionSummary(completedTx, space);
+        const value = result.withTx(completedTx).get();
+
+        resolve({ value, summary });
+      });
     } else {
</file context>
Fix with Cubic

});
} else {
throw new Error("Tool has neither pattern nor handler");
}
Expand Down
6 changes: 6 additions & 0 deletions packages/runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export type {
IExtendedStorageTransaction,
MemorySpace,
} from "./storage/interface.ts";
export {
debugTransactionWrites,
formatTransactionSummary,
summarizeTransaction,
type TransactionSummary,
} from "./storage/transaction-summary.ts";
export { convertCellsToLinks, isCell, isStream } from "./cell.ts";
export {
getCellOrThrow,
Expand Down
Loading