Skip to content

fix(schema): declare array items for upsert_event tool to satisfy OpenAI strict mode#224

Merged
chubes4 merged 1 commit intomainfrom
fix-array-schema-items
May 2, 2026
Merged

fix(schema): declare array items for upsert_event tool to satisfy OpenAI strict mode#224
chubes4 merged 1 commit intomainfrom
fix-array-schema-items

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented May 1, 2026

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.

…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.
@homeboy-ci
Copy link
Copy Markdown
Contributor

homeboy-ci Bot commented May 1, 2026

Homeboy Results — data-machine-events

Audit

audit — passed

  • test_coverage — 1 finding(s)
  • Total: 1 finding(s)

Deep dive: homeboy audit data-machine-events --changed-since f371a2a

Tooling versions
  • Homeboy CLI: homeboy 0.142.0+5a19d01
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: 9d5b873
  • Action: Extra-Chill/homeboy-action@v2

@chubes4 chubes4 merged commit 3f41be4 into main May 2, 2026
1 check passed
@chubes4 chubes4 deleted the fix-array-schema-items branch May 2, 2026 13:20
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.

1 participant