Skip to content

feat: redact known credential values from tool output sent to the model - #1821

Draft
anandgupta42 wants to merge 9 commits into
mainfrom
fix/redact-credentials-in-tool-output
Draft

anandgupta42 wants to merge 9 commits into
mainfrom
fix/redact-credentials-in-tool-output

Conversation

@anandgupta42

@anandgupta42 anandgupta42 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

No tracking issue.

Type of change

  • Bug fix

What does this PR do?

Filter exact matches for known credential values in shell, file, search, and MCP tool output before delivery or session storage. Preserve ordinary final output and structured field names. Live shell previews hold a trailing window sized for known credential values and their encoded forms.

How did you verify your code works?

  • Synthetic fixtures separately verify streaming progress, SQLite persistence, and replay of raw historical results. Coverage also includes connection JSON and URLs, tool errors, multiline file output, and JSON escape variants.
  • Focused tool, session, connection, and ripgrep suites passed. Both package typechecks and the strict upstream marker audit passed.
  • Read-only reviews covered a30defc220b1524ae618f21d15ce8a4e9821424d and 31078cca44599608712b708f9b91f7c61041dd31. Follow-up fixes were verified at b055428b6b8477d11498e18da730a7be64926c05.
  • A separate non-regression check is pending.

Cost side effects

None.

Screenshots / recordings

No UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@anandgupta42

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T08:34:40.240706Z c3266cc Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3266ccc27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +445 to +446
const connections = Instance.restore(instance, () => Connections.knownCredentialConfigs())
for (const connection of connections) addConnectionFields(connection, add)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve credential configs using the supplied instance

When the caller carries its project only through InstanceRef, as the HTTP API instance-context middleware does, this restore does not cover the credential lookup: knownCredentialConfigs() is a generator, so its body runs during the subsequent iteration, after Instance.restore() has exited. Its projectRoot() then falls back to the server's working directory instead of the requested project. Consequently, project-local and in-memory warehouse credentials are omitted from the redactor, allowing tool results containing those secrets to reach session storage and the model unmasked. Pass the instance directory explicitly into the lookup rather than relying on ambient context around generator creation.

AGENTS.md reference: packages/opencode/AGENTS.md:L144-L144

Useful? React with 👍 / 👎.

@anandgupta42 anandgupta42 changed the title fix: redact known credential values from tool output sent to the model feat: redact known credential values from tool output sent to the model Nov 22, 2026
@github-actions

Copy link
Copy Markdown

Thanks for updating your PR! It now meets our contributing guidelines. 👍

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant