fix(schema): declare array items for upsert_event tool to satisfy OpenAI strict mode#224
Merged
fix(schema): declare array items for upsert_event tool to satisfy OpenAI strict mode#224
Conversation
…nAI strict mode
Production fire on events.extrachill.com — every event ingestion flow has been
failing since the wp-ai-client cutover with:
Bad Request (400) - Invalid schema for function 'upsert_event':
In context=('properties', 'occurrenceDates'),
array schema missing items.
OpenAI's strict tool schema validation requires `items` on every array type.
The previous ai-http-client tolerated the omission; wp-ai-client does not.
Two changes:
1. Declare `items` on the `occurrenceDates` field in EventSchemaProvider — the
field stores ISO date strings (YYYY-MM-DD), so `items: { type: string }`.
2. Harden `fieldsToToolParameters()` to always emit `items` for `type: array`.
Falls back to `{ type: string }` when the field declaration is incomplete,
so future array fields cannot silently regress this bug.
Verified the fix produces a schema that passes OpenAI strict validation. Event
ingestion flows should resume on next pipeline tick after deploy.
Contributor
Homeboy Results —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Production fire
Every event ingestion flow on events.extrachill.com has been failing since the wp-ai-client cutover (DM 0.103.x) with:
```
Bad Request (400) - Invalid schema for function 'upsert_event':
In context=('properties', 'occurrenceDates'), array schema missing items.
```
OpenAI's strict tool schema validation requires `items` on every array type. The legacy ai-http-client tolerated the omission silently; wp-ai-client does not (correctly — this was always invalid JSON Schema).
Impact
`occurrenceDates` is a field on the `upsert_event` tool — the AI's primary path for writing events into WordPress. Without it working, no events get ingested:
```
status count recent flows affected
failed - ai_processing_failed N Dice.fm, Squarespace, Universal scrapers
completed_no_items N everything else (dedup says nothing new)
new events created in 4h: 0
```
Fix
1. Declare `items` on `occurrenceDates` in EventSchemaProvider
`occurrenceDates` stores ISO date strings (YYYY-MM-DD), so:
```php
'occurrenceDates' => array(
'type' => 'array',
'items' => array( 'type' => 'string' ), // ← added
'required' => false,
'description' => 'For recurring events: array of specific dates (YYYY-MM-DD)...',
'schema_property' => null,
),
```
2. Harden `fieldsToToolParameters()` to always emit `items` for arrays
Defensive: any future array field that forgets to declare `items` will get a sensible default instead of producing an invalid schema.
```php
if ( 'array' === ( $field['type'] ?? '' ) ) {
$param['items'] = $field['items'] ?? array( 'type' => 'string' );
}
```
Verification
After applying, the generated schema for `upsert_event` validates cleanly against OpenAI's strict mode. Event ingestion flows resume on next pipeline tick.
Out of scope
Several output schemas in DM-events ability declarations (DiceFmTest, EventHealthAbilities, BatchTimeFixAbilities) also have `type: array` without `items`. Those are descriptive-only metadata for ability returns and don't go to OpenAI as tool definitions — they're not blocking production. Worth a separate cleanup PR for completeness.
Refs: extrachill.com production incident May 1 2026 ~19:00 UTC after wp-ai-client cutover deploy.