Michael Neale fb1119cc02 BRAINROT P2: per-field cap inside code_execution result bundles
The code_execution sandbox encourages the model to bundle multiple
sub-tool calls and return one labeled object like
'Result: { foo, bar, baz }'. Without per-field truncation, a single fat
field (full source file, build log, large query result) bloats the
whole bundle even when the other fields are tiny and useful.

Add truncate_execute_output() which intercepts pctx_code_mode's
ExecuteOutput just before output.markdown() is called and:

  - caps stdout and stderr if they exceed the per-field cap,
  - walks the  JSON value tree and truncates any leaf string
    longer than the cap with a marker.

Truncation is UTF-8 safe and recursive (nested objects + arrays). The
top-level P0 cap (16 KB on the whole tool_result text) still applies as
a backstop; this P2 cap (8 KB per field by default) operates earlier so
that one large field can't drown out the small useful ones in the same
bundle.

- Defaults: 8192 bytes per string field.
- Tunable: GOOSE_CODE_EXEC_FIELD_MAX_BYTES (0 to disable).
- Applied to both handle_execute_typescript and handle_execute_bash
  (execute_bash also wraps a bash invocation whose stdout/stderr can be
  large; same treatment).

Three serial unit tests cover (a) leaf-only truncation across object,
array, and nested object, (b) end-to-end ExecuteOutput cap, (c) env
disable.

Signed-off-by: Michael Neale <michael.neale@gmail.com>
2026-05-20 19:10:57 +10:00
2026-05-11 16:02:44 +00:00
2026-03-07 17:16:19 +00:00
…

🦆 goose has moved! This project has moved from block/goose to the Agentic AI Foundation (AAIF) at the Linux Foundation. Some links and references are still being updated — please bear with us during the transition.

goose

your native open source AI agent — desktop app, CLI, and API — for code, workflows, and everything in between

Discord CI

goose is a general-purpose AI agent that runs on your machine. Not just for code — use it for research, writing, automation, data analysis, or anything you need to get done.

A native desktop app for macOS, Linux, and Windows. A full CLI for terminal workflows. An API to embed it anywhere. Built in Rust for performance and portability.

goose works with 15+ providers — Anthropic, OpenAI, Google, Ollama, OpenRouter, Azure, Bedrock, and more. Use API keys or your existing Claude, ChatGPT, or Gemini subscriptions via ACP. Connect to 70+ extensions via the Model Context Protocol open standard.

goose is part of the Agentic AI Foundation (AAIF) at the Linux Foundation.

Get started

Download the desktop app for macOS, Linux, and Windows.

Or install the CLI:

curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh | bash

Quick links

Need help?

a little goose humor 🪿

Why did the developer choose goose as their AI agent?

Because it always helps them "migrate" their code to production! 🚀

goose around with us

S
Description
No description provided
Readme Apache-2.0 1.5 GiB
Languages
Rust 63.6%
TypeScript 29.6%
JavaScript 1.7%
Shell 1.6%
Python 1.5%
Other 1.8%