Skip to content

Shell tool output duplicated to LLM: audience filtering not applied to tool results #6703

@GordianDziwis

Description

@GordianDziwis

Describe the bug

Shell tool output is duplicated in the function result returned to the agent. The user sees normal single output in their terminal, but the agent receives every line twice.

This wastes context window tokens and causes confusion - in my session, the agent incorrectly reported that config files had duplicated content when they did not.


To Reproduce

  1. Start a goose CLI session
  2. Have the agent run any shell command, e.g. uname -a
  3. The agent receives the output twice in the tool result

Expected behavior

Agent receives the output once.

Actual behavior

Agent receives the output twice. Looking at the session JSON, the toolResult.value.content array contains two identical text entries:

"content": [
  {
    "type": "text",
    "text": "extensions:\n  developer:\n  ...",
    "annotations": {
      "audience": ["assistant"]
    }
  },
  {
    "type": "text",
    "text": "extensions:\n  developer:\n  ...",   // <-- IDENTICAL TEXT
    "annotations": {
      "audience": ["user"],
      "priority": 0.0
    }
  }
]

The code in crates/goose-mcp/src/developer/mod.rs intentionally returns two Content items with different audiences, but for shell output they contain the same text:

Ok(vec![
    Content::text(output_str.clone()).with_audience(vec![Role::Assistant]),
    Content::text(output_str)
        .with_audience(vec![Role::User])
        .with_priority(0.0),
])

The bug is that both audience-tagged content items are being sent to the LLM context, when only the assistant audience should be.


Screenshots

N/A - the duplication is not visible to the user, only in what the agent receives.


Please provide the following information

  • OS & Arch: Arch Linux x86_64 (kernel 6.18.5-arch1-1)
  • Interface: CLI
  • Version: 1.21.1
  • Extensions enabled: developer, extensionmanager, todo
  • Provider & Model: Anthropic – claude-opus-4-5-20251101

Additional context

The issue is in how tool results are filtered before being sent to the LLM. The audience annotation should filter content so only assistant-targeted content goes to the model, but currently both are included.

See crates/goose-mcp/src/developer/mod.rs for the shell tool implementation that returns dual-audience content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions