Skip to content

Conversation

@rabi
Copy link
Contributor

@rabi rabi commented Jan 27, 2026

Summary

Move filtering to stream_response_from_provider() so providers receive pre-filtered messages.

Type of Change

  • Feature
  • [] Bug fix
  • Refactor / Code quality
  • Performance improvement
  • Documentation
  • Tests
  • Security fix
  • Build / Release
  • Other (specify below)

Testing

Tested with anthropic provider.

Before the fix:

"content": "Linux ramishra-thinkpadp1gen7.rmtin.csb 6.18.5-200.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 11 17:09:32 UTC 2026 x86_64 GNU/Linux\n\nLinux ramishra-thinkpadp1gen7.rmtin.csb 6.18.5-200.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 11 17:09:32 UTC 2026 x86_64 GNU/Linux\n"
The uname -a output appeared twice (separated by a blank line).

After the fix:
"content": "Linux ramishra-thinkpadp1gen7.rmtin.csb 6.18.5-200.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Jan 11 17:09:32 UTC 2026 x86_64 GNU/Linux\n"
The output appears only once.

Closes: #6703

@rabi rabi force-pushed the 6703 branch 2 times, most recently from 9c31467 to c33dc9c Compare January 27, 2026 08:46
@DOsinga
Copy link
Collaborator

DOsinga commented Jan 27, 2026

@rabi
Copy link
Contributor Author

rabi commented Jan 27, 2026

so https://github.com/block/goose/pull/6646/files#diff-0ceb972208a9cbe6f665656b11f613ea51588bedeeace7bfeae766302d8ea332 introduces filter_for_audience, can we use that here?

That's a good idea. Moving filtering earlier in the pipeline to the agent level using agent_visible_content() would be cleaner and easier to maintain, but it involves cloning entire Message structures upfront rather than filtering during extraction. Happy to refactor if the tradeoff is acceptable.

@DOsinga
Copy link
Collaborator

DOsinga commented Jan 27, 2026

yeah, but you could just call that on the filter_map(|c| { ? that should be a content object that has the filter, no?

@rabi
Copy link
Contributor Author

rabi commented Jan 28, 2026

yeah, but you could just call that on the filter_map(|c| { ? that should be a content object that has the filter, no?

Isn't filter_for_audience a method on MessageContent (goose type) and not on Content (rmcp type in tool results)? At present, inline filtering operates on Content items directly. I think what you're suggesting would involve adding filter_for_audience method to Content in rmcp crate or extension trait pattern to add methods to external types.

DOsinga pushed a commit that referenced this pull request Jan 28, 2026
Instead of inline filtering at the Content level in each format handler,
filter at the Message level using the existing filter_for_audience()
method via agent_visible_content(). This:

- Eliminates code duplication across format handlers
- Uses the centralized filtering logic from filter_for_audience
- Makes the code more maintainable and consistent

The filtering now happens once before format_messages/conversion
functions rather than inline during content iteration.

Addresses review feedback from DOsinga on PR #6728.
DOsinga pushed a commit that referenced this pull request Jan 28, 2026
Instead of inline filtering at the Content level in each format handler,
filter at the Message level using the existing filter_for_audience()
method via agent_visible_content(). This:

- Eliminates code duplication across format handlers
- Uses the centralized filtering logic from filter_for_audience
- Makes the code more maintainable and consistent

The filtering now happens inside format_messages() and similar functions
rather than requiring callers to filter before calling these functions.

Addresses review feedback from DOsinga on PR #6728.
Move filtering to stream_response_from_provider() so providers receive
pre-filtered messages.

Signed-off-by: rabi <[email protected]>
@rabi rabi changed the title fix: filter tool result content by audience refactor: centralize audience filtering before providers receive messages Jan 29, 2026
@DOsinga DOsinga merged commit 0a55817 into block:main Jan 29, 2026
18 checks passed
zanesq added a commit that referenced this pull request Jan 29, 2026
* 'main' of github.com:block/goose: (62 commits)
  Swap canonical model from openrouter to models.dev (#6625)
  Hook thinking status (#6815)
  Fetch new skills hourly (#6814)
  copilot instructions: Update "No prerelease docs" instruction (#6795)
  refactor: centralize audience filtering before providers receive messages (#6728)
  update doc to remind contributors to activate hermit and document minimal npm and node version (#6727)
  nit: don't spit out compaction when in term mode as it fills up the screen (#6799)
  fix: correct tool support detection in Tetrate provider model fetching (#6808)
  Session manager fixes (#6809)
  fix(desktop): handle quoted paths with spaces in extension commands (#6430)
  fix: we can default gooseignore without writing it out (#6802)
  fix broken link (#6810)
  docs: add Beads MCP extension tutorial (#6792)
  feat(goose): add support for AWS_BEARER_TOKEN_BEDROCK environment variable (#6739)
  [docs] Add OSS Skills Marketplace (#6752)
  feat: make skills available in codemode (#6763)
  Fix: Recipe Extensions Not Loading in Desktop (#6777)
  Different approach to determining final confidence level of prompt injection evaluation outcomes (#6729)
  fix: read_resource_tool deadlock causing test_compaction to hang (#6737)
  Upgrade error handling (#6747)
  ...
zanesq added a commit that referenced this pull request Jan 29, 2026
…sion-session

* 'main' of github.com:block/goose: (78 commits)
  copilot instructions: Update "No prerelease docs" instruction (#6795)
  refactor: centralize audience filtering before providers receive messages (#6728)
  update doc to remind contributors to activate hermit and document minimal npm and node version (#6727)
  nit: don't spit out compaction when in term mode as it fills up the screen (#6799)
  fix: correct tool support detection in Tetrate provider model fetching (#6808)
  Session manager fixes (#6809)
  fix(desktop): handle quoted paths with spaces in extension commands (#6430)
  fix: we can default gooseignore without writing it out (#6802)
  fix broken link (#6810)
  docs: add Beads MCP extension tutorial (#6792)
  feat(goose): add support for AWS_BEARER_TOKEN_BEDROCK environment variable (#6739)
  [docs] Add OSS Skills Marketplace (#6752)
  feat: make skills available in codemode (#6763)
  Fix: Recipe Extensions Not Loading in Desktop (#6777)
  Different approach to determining final confidence level of prompt injection evaluation outcomes (#6729)
  fix: read_resource_tool deadlock causing test_compaction to hang (#6737)
  Upgrade error handling (#6747)
  Fix/filter audience 6703 local (#6773)
  chore: re-sync package-lock.json (#6783)
  upgrade electron to 39.3.0 (#6779)
  ...
lifeizhou-ap added a commit that referenced this pull request Jan 29, 2026
* main:
  docs: usage data collection (#6822)
  feat: platform extension migrator + code mode rename (#6611)
  feat: CLI flag to skip loading profile extensions (#6780)
  Swap canonical model from openrouter to models.dev (#6625)
  Hook thinking status (#6815)
  Fetch new skills hourly (#6814)
  copilot instructions: Update "No prerelease docs" instruction (#6795)
  refactor: centralize audience filtering before providers receive messages (#6728)
  update doc to remind contributors to activate hermit and document minimal npm and node version (#6727)
  nit: don't spit out compaction when in term mode as it fills up the screen (#6799)
  fix: correct tool support detection in Tetrate provider model fetching (#6808)
  Session manager fixes (#6809)
  fix(desktop): handle quoted paths with spaces in extension commands (#6430)
  fix: we can default gooseignore without writing it out (#6802)
  fix broken link (#6810)
  docs: add Beads MCP extension tutorial (#6792)
  feat(goose): add support for AWS_BEARER_TOKEN_BEDROCK environment variable (#6739)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants