Skip to content

fix(tools): make object schemas OpenAI-safe - #1232

Merged
penso merged 1 commit into
moltis-org:mainfrom
IlyaBizyaev:fix/tool-schemas
Aug 27, 2026
Merged

fix(tools): make object schemas OpenAI-safe#1232
penso merged 1 commit into
moltis-org:mainfrom
IlyaBizyaev:fix/tool-schemas

Conversation

@IlyaBizyaev

@IlyaBizyaev IlyaBizyaev commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

OpenAI strict tool schemas close objects with additionalProperties=false. Unspecified patch and map schemas therefore forced Codex to send null or empty values instead of the requested data.

Declare the webhook patch fields, represent MCP environment variables as fixed name/value entries, and provide JSON-string alternatives for free-form webhook configuration and Home Assistant data objects. Normalize these representations before dispatch, including strict-generated nulls in nested webhook filters.

I changed the MCP env tool argument from a free-form object to an array of {name, value} entries so it's expressible under strict OpenAI schemas. There is no need to preserve backwards compatibility with the old format here: it's a rarely used tool, and models are expected to respond with the new format now based on schema they receive with every request.

Nullable webhook fields were already not clearable with any provider, this is not a regression. This change enables ordinary OpenAI updates but does not lift that pre-existing limitation.

@IlyaBizyaev

Copy link
Copy Markdown
Contributor Author

The issue I'm fixing here is that with Codex, the agent fails to use the cron tool to update an existing job: it thinks it keeps supplying an empty patch object in a loop.

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR makes agent-tool object arguments compatible with strict OpenAI schemas and normalizes their alternate wire representations before dispatch.

  • Represents MCP environment variables as name/value entries and converts them to the service’s object-map format.
  • Supports JSON-encoded Home Assistant data objects.
  • Defines webhook patch fields and normalizes JSON-encoded configuration and strict-generated nested nulls.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/gateway/src/mcp_agent_tools.rs Replaces the MCP environment map schema with strict-compatible entries and normalizes them before service dispatch.
crates/home-assistant/src/tool.rs Adds JSON-string alternatives for Home Assistant data objects and validates them before live operations.
crates/tools/src/webhook_tool.rs Expands the webhook patch schema and normalizes stringified configuration objects and nested null filters.

Reviews (2): Last reviewed commit: "fix(tools): make object schemas OpenAI-s..." | Re-trigger Greptile

Comment thread crates/gateway/src/mcp_agent_tools.rs
OpenAI strict tool schemas close objects with additionalProperties=false.
Unspecified patch and map schemas therefore forced Codex to send null or
empty values instead of the requested data.

Declare the webhook patch fields, represent MCP environment variables as
fixed name/value entries, and provide JSON-string alternatives for
free-form webhook configuration and Home Assistant data objects.
Normalize these representations before dispatch, including
strict-generated nulls in nested webhook filters.

I changed the MCP `env` tool argument from a free-form object to an
array of `{name, value}` entries so it's expressible under strict OpenAI
schemas. There is no need to preserve backwards compatibility with the
old format here: it's a rarely used tool, and models are expected to
respond with the new format now based on schema they receive with every
request.

Nullable webhook fields were already not clearable with any provider,
this is not a regression. This change enables ordinary OpenAI updates
but does not lift that pre-existing limitation.
@IlyaBizyaev

Copy link
Copy Markdown
Contributor Author

#1226 happened to do the cron part of these changes, so I've now rebased what's left on top of it

@penso

penso commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

@greptileai review

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.

2 participants