The open-source agent harness - the runtime layer that turns an LLM into a working agent.
Increase bias for openui and also propagate error for deferred tools
Chirag Jain354991d49410
diff --git a/.changeset/openui-chart-plot-bias.md b/.changeset/openui-chart-plot-bias.mdnew file mode 100644index 000000000..34c5062fb--- /dev/null+++ b/.changeset/openui-chart-plot-bias.md@@ -0,0 +1,5 @@+---+'@truefoundry/trueforge-core': patch+---++Prefer OpenUI for inline charts over sandbox plot images when OpenUI is available.diff --git a/packages/trueforge-core/src/core/capabilities/builtins/OpenUI.ts b/packages/trueforge-core/src/core/capabilities/builtins/OpenUI.tsindex 043626199..2229f058f 100644--- a/packages/trueforge-core/src/core/capabilities/builtins/OpenUI.ts+++ b/packages/trueforge-core/src/core/capabilities/builtins/OpenUI.ts@@ -227,6 +227,7 @@ export function buildOpenUIInstruction(builder: InstructionBuilder): void {OPENUI_IMPORTANT_RULES_TAG,dedent`- When asked about data, generate realistic/plausible data+ - Prefer OpenUI charts for plot/chart/visualize; images only if downloadable- Choose components that best represent the content (tables for comparisons, charts for trends, forms for input, etc.)- When you render data in an openui block (tables, charts, KPI cards), do NOT repeat the same numbers/facts in the markdown text outside the block.- Text outside the openui block can optionally include:@@ -256,7 +257,7 @@ export function buildOpenUIInstruction(builder: InstructionBuilder): void {openui.addSection(OPENUI_USER_INTERACTION_CHECKLIST_TAG,dedent`- 1. Will the response be UI heavy and will contain components which are not supported by markdown? Use openui if the answer is yes.+ 1. Plot/chart/visualize or UI-heavy beyond markdown? Use openui.2. \`\`\`openui\`\`\` fencing must be closed.`,);}@@ -285,7 +286,8 @@ function buildOpenUIDeferredInstruction(builder: InstructionBuilder): void {Before writing any \`\`\`openui fence, the Agent MUST call ${GET_OPENUI_INSTRUCTIONS_TOOL_NAME} with arguments {}.Do not invent OpenUI syntax or component APIs without loading those instructions.- Use OpenUI only when the response is UI-heavy and needs components markdown does not support.+ Prefer OpenUI for plot/chart/visualize over sandbox code; sandbox images only for downloads.+ Otherwise use OpenUI only when UI-heavy beyond markdown.`.trim(),);}diff --git a/packages/trueforge-core/src/core/runtime/DeferredTool.ts b/packages/trueforge-core/src/core/runtime/DeferredTool.tsindex 605d847f8..fb789c168 100644--- a/packages/trueforge-core/src/core/runtime/DeferredTool.ts+++ b/packages/trueforge-core/src/core/runtime/DeferredTool.ts@@ -192,7 +192,9 @@ export class DeferredTool extends LocalToolMCP {mcpServer: input.mcp_server,});return toolResultResponse({- text: JSON.stringify({ error: `Failed to list tools for '${input.mcp_server}'.` }),+ text: JSON.stringify({+ error: `Failed to list tools for '${input.mcp_server}': ${error instanceof Error ? error.message : 'unknown'}`,+ }),isError: true,});}diff --git a/packages/trueforge-core/src/core/sandbox/Sandbox.ts b/packages/trueforge-core/src/core/sandbox/Sandbox.tsindex 4d7e79e3b..47eac9169 100644--- a/packages/trueforge-core/src/core/sandbox/Sandbox.ts+++ b/packages/trueforge-core/src/core/sandbox/Sandbox.ts@@ -295,6 +295,9 @@ export class Sandbox extends LocalToolMCP {const sandboxInstructions = builder.beginSection('sandbox');sandboxInstructions.addContent('The Agent has access to a persistent sandbox environment for executing code.');sandboxInstructions.addContent('The Agent must NOT read or modify any git credential files.');+ sandboxInstructions.addContent(+ 'Prefer OpenUI for inline charts when available; sandbox chart images only for downloads.',+ );this.buildSchemaSection(sandboxInstructions);this.buildSkillsSection(sandboxInstructions);@@ -345,7 +348,7 @@ export class Sandbox extends LocalToolMCP {[Human-readable label](/absolute/path/to/file.ext)\`\`\`- For large outputs or content that can be generated through code, prefer writing to a file and emitting the sandbox_artifacts block.+ For large outputs or downloadable artifacts that can be generated through code, prefer writing to a file and emitting the sandbox_artifacts block.Rules:- Use absolute paths, not ~/ or relative paths.