Skip to content

🧳 fix: Skip Agent Tool Schemas During File Inspection - #16804

Draft
dustinhealy wants to merge 2 commits into
devfrom
fix/agent-file-reference-inspection
Draft

dustinhealy wants to merge 2 commits into
devfrom
fix/agent-file-reference-inspection

Conversation

@dustinhealy

@dustinhealy dustinhealy commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Agent file-reference inspection traverses the complete initialized runtime agent whenever the agent has a hydrated attachment. Runtime agents can also contain deeply nested initialized tool definitions, causing locator sanitization to exceed its traversal depth and reject otherwise valid attachment turns with content_filter_uninspectable.

This change omits only the top-level toolDefinitions branch while sanitizing resolved agent file locators. All other agent fields, including instructions, model parameters, attachments, and tool resources, remain subject to opaque-file inspection. Tool definitions continue through their existing source-specific content inspection path.

How it works

omitResolvedCanonicalFileLocators now accepts a bounded set of root keys to omit from its inspection copy. The agent path uses that option for toolDefinitions, avoiding traversal of initialized schemas without weakening inspection of other provider-bound fields.

Type of change

  • Bug fix
  • Tests / tooling / CI

Testing

The regression coverage verifies both sides of the boundary:

  • A hydrated request attachment no longer causes a deeply nested initialized tool schema to exhaust file-locator traversal.
  • Opaque file payloads in agent instructions and model request fields still fail closed.
  • Existing unresolved agent resource references continue to fail closed.

Tested environments/configuration:

  • Agents endpoint
  • Source-aware content filtering
  • Hydrated request attachment
  • Initialized tool definitions

Automated tests:

  • npm test --prefix packages/api -- --runInBand --coverage=false --watch=false modelBoundContent.spec.ts
  • 198 tests passed
  • prettier --check <changed files>
  • eslint <changed files>

Screenshots / recordings

No visual UI change; this is backend content-validation behavior.

Risk / compatibility

The omission is limited to initialized tool definitions at the agent root. Provider-bound agent fields and unresolved file references retain fail-closed behavior.

Checklist

  • I reviewed my own changes
  • Relevant tests have been added or updated
  • Existing relevant tests pass
  • The change does not introduce new warnings or errors
  • User-facing or complex behavior is documented where necessary
  • Required dependency changes have been merged/published
  • Required documentation PR: N/A

Copilot AI balanced review requested due to automatic review settings October 6, 2026 02:23
@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T02:38:50.071612Z fcb1c37 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused change preserves file validation and source-specific inspection, with regression coverage and no unresolved findings.

Review effort: Balanced
Findings: None

What changed in this PR

Limits agent file-reference inspection to file-bearing fields, preventing unrelated nested tool schemas from rejecting valid attachment turns.

Changes:

  • Projects the four supported file-bearing fields before opaque-file validation.
  • Adds a regression test for hydrated attachments alongside deeply nested tool schemas.
File Description
packages/​api/​src/​middleware/​modelBoundContent.ts Restricts file-reference inspection to supported runtime fields.
packages/​api/​src/​middleware/​modelBoundContent.spec.ts Tests that unrelated tool schemas do not trigger traversal failures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@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: eb2e6bb5e5

ℹ️ 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 thread packages/api/src/middleware/modelBoundContent.ts Outdated
@dustinhealy dustinhealy changed the title 🧳 fix: Limit Agent File Inspection to File References 🧳 fix: Skip Agent Tool Schemas During File Inspection Oct 6, 2026
@dustinhealy

Copy link
Copy Markdown
Collaborator Author

@codex review

@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: fcb1c373c9

ℹ️ 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".

resolvedFilesById: ReadonlyMap<string, CanonicalFileInspectionFile>,
context: {
readonly messageCount?: number;
readonly omittedRootKeys?: ReadonlySet<string>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor root omissions when no files resolve

When files.pii.uninspectable is block and an agent has no hydrated file with a usable file_id, agentFilesById is empty, so the early return at line 1154 ignores this new omittedRootKeys option. assertInspectableFileInput consequently receives the original agent and still traverses toolDefinitions; a sufficiently deep or large initialized schema rejects an otherwise valid attachment-free turn as content_filter_uninspectable. Apply the root-key omission even for an empty resolved-file map, and retain the fast path only when no omissions were requested.

Useful? React with 👍 / 👎.

MAX_PROVIDER_PROVENANCE_INDEX_REFS + MAX_PROVIDER_PROVENANCE_PARTS;
const MAX_PROVIDER_STORED_STATE_WORK =
MAX_PROVIDER_PROJECTION_WORK + MAX_PROVIDER_PROVENANCE_PARTS * 2;
const AGENT_FILE_INSPECTION_OMITTED_ROOT_KEYS = new Set(['toolDefinitions']);

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 Inspect caller-supplied tool definitions before omitting schemas

With files.pii.uninspectable: block, a Responses API caller can place an opaque file payload such as data:application/pdf;base64,... in a function tool's description or parameters and have it sent to the provider whenever the agent also has a hydrated attachment. Fresh evidence beyond the earlier thread is that api/server/controllers/agents/responses.js:1136-1145 merges request.tools into primaryConfig.toolDefinitions after the initial check at line 1078, while the post-merge check at line 1196 reaches this new omission; extractAgentContent then subjects the schema only to tool-argument/agent-instruction policies, not the file policy. Preserve opaque-file validation for caller-supplied definitions before omitting trusted initialized schemas.

Useful? React with 👍 / 👎.

@codegraph-librechat codegraph-librechat Bot added 🗺️ Content Safety codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) 🗺️ Platform Security codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) labels Oct 6, 2026

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

Labels

🗺️ Content Safety codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9) 🗺️ Platform Security codegraph: the taxonomy area this belongs to (classifier, confidence ≥ 0.9)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants