Skip to content

[BUG] Sandbox tool: Redundant token usage due to repeated content in stdout and summary #1140

@Diluka

Description

@Diluka

Describe the bug

When using the sandbox tool to execute commands, the stdout output and the summary output are often almost identical. This leads to significant token redundancy and inefficiency.

For example, running a command such as cat /skills/examples/playwright-cli/SKILL.md produces a stdout and summary that both contain the full file content, resulting in double the token usage with no extra information provided by the summary. This is an issue especially for large outputs, as it wastes computational resources and impacts performance.

Data Example:

{
  "type": "tool-execute_command",
  "input": {
    "args": [
      "/skills/examples/playwright-cli/SKILL.md"
    ],
    "command": "cat"
  },
  "state": "output-available",
  "output": {
    "type": "json",
    "value": {
      "stderr": "",
      "stdout": "---\nname: playwright-cli\ndescription: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.\nallowed-tools: Bash(playwright-cli:*)\n---\n\n# Browser Automation with playwright-cli\n\n## Quick start\n...<OMITTED FOR BREVITY>...",
      "aborted": false,
      "success": true,
      "summary": "Exit code: 0\nDuration: 78 ms\nSTDOUT:\n---\nname: playwright-cli\ndescription: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.\nallowed-tools: Bash(playwright-cli:*)\n---\n\n# Browser Automation with playwright-cli\n\n## Quick start\n...<OMITTED FOR BREVITY>...\n\nSTDERR: (empty)",
      "exit_code": 0,
      "timed_out": false,
      "duration_ms": 78,
      "stderr_truncated": false,
      "stdout_truncated": false
    }
  },
  "toolCallId": "toolu_vrtx_01RbrpyoaxK7AFyCUfy2YeZ6",
  "providerExecuted": false
}

Steps To Reproduce

  1. Use the sandbox tool to run a command, for example: cat /skills/examples/playwright-cli/SKILL.md
  2. Observe the returned stdout and the summary. Both contain the same or highly similar content for the command output.
  3. Note the total token count for the sandbox tool response.

Expected behavior

The summary should only include brief metadata (such as exit code, duration, and possibly a short description), not a verbatim or near-verbatim copy of the stdout.
stdout should contain the full command output, but the summary should avoid repeating the content to reduce wasted tokens.

Packages

  • @voltagent/core
  • @voltagent/sandbox-e2b

Additional Context

This issue impacts scenarios where large command outputs are involved, as it can dramatically increase response size and token costs for both users and AI models. Optimizing the summary to avoid duplicating large text from stdout would be very beneficial.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions