Skip to content

fix(chat-tools): canonical JSON Schema across inc/Api/Chat/Tools/#1923

Merged
chubes4 merged 1 commit into
mainfrom
fix-canonical-chat-tools
May 10, 2026
Merged

fix(chat-tools): canonical JSON Schema across inc/Api/Chat/Tools/#1923
chubes4 merged 1 commit into
mainfrom
fix-canonical-chat-tools

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented May 10, 2026

Why

DM 0.106.1 PR #1900 ("Require canonical AI tool schemas") removed the auto-normalization layer in RequestBuilder::normalizeToolParameters. Tool registrations now go to OpenAI as the schema literal — anything still emitting the legacy {name => {type, required: true|false, description}} shape gets rejected by provider strict-mode validation.

This PR sweeps all chat tools in inc/Api/Chat/Tools/. Two parallel PRs cover the other in-scope buckets identified by issue #1921: Global tools (inc/Engine/AI/Tools/Global/) and handler tools (inc/Core/Steps/Publish/Handlers/{WordPress,Email}/). This PR stays out of those directories.

Closes part of #1921.

What changed

Converted 31 chat tool definitions from the legacy shape:

// Legacy
'parameters' => array(
    'flow_id' => array( 'type' => 'integer', 'required' => true, 'description' => 'Flow ID' ),
    'flow_name' => array( 'type' => 'string', 'required' => false, 'description' => 'Flow name' ),
)

…to canonical JSON Schema:

// Canonical
'parameters' => array(
    'type'       => 'object',
    'properties' => array(
        'flow_id'   => array( 'type' => 'integer', 'description' => 'Flow ID' ),
        'flow_name' => array( 'type' => 'string',  'description' => 'Flow name' ),
    ),
    'required'   => array( 'flow_id' ),
)

Files

  • inc/Api/Chat/Tools/AddPipelineStep.php
  • inc/Api/Chat/Tools/ApiQuery.php
  • inc/Api/Chat/Tools/AssignTaxonomyTerm.php
  • inc/Api/Chat/Tools/AuthenticateHandler.php
  • inc/Api/Chat/Tools/ConfigureFlowSteps.php
  • inc/Api/Chat/Tools/ConfigurePipelineStep.php
  • inc/Api/Chat/Tools/CopyFlow.php
  • inc/Api/Chat/Tools/CreateFlow.php
  • inc/Api/Chat/Tools/CreatePipeline.php
  • inc/Api/Chat/Tools/CreateTaxonomyTerm.php
  • inc/Api/Chat/Tools/DeleteFile.php
  • inc/Api/Chat/Tools/DeleteFlow.php
  • inc/Api/Chat/Tools/DeletePipeline.php
  • inc/Api/Chat/Tools/DeletePipelineStep.php
  • inc/Api/Chat/Tools/ExecuteWorkflowTool.php
  • inc/Api/Chat/Tools/GetHandlerDefaults.php
  • inc/Api/Chat/Tools/GetProblemFlows.php
  • inc/Api/Chat/Tools/ListFlows.php
  • inc/Api/Chat/Tools/ManageJobs.php
  • inc/Api/Chat/Tools/ManageLogs.php
  • inc/Api/Chat/Tools/ManageQueue.php
  • inc/Api/Chat/Tools/MergeTaxonomyTerms.php
  • inc/Api/Chat/Tools/ReadLogs.php
  • inc/Api/Chat/Tools/ReorderPipelineSteps.php
  • inc/Api/Chat/Tools/RunFlow.php
  • inc/Api/Chat/Tools/SearchTaxonomyTerms.php
  • inc/Api/Chat/Tools/SendPing.php
  • inc/Api/Chat/Tools/SetHandlerDefaults.php
  • inc/Api/Chat/Tools/SystemHealthCheck.php
  • inc/Api/Chat/Tools/UpdateFlow.php
  • inc/Api/Chat/Tools/UpdateTaxonomyTerm.php

SchedulingDocumentation.php is a helper class with no tool parameters and was not modified.

Conversion rules applied

Identical to the rules used in Extra-Chill/data-machine-events#232 / #235:

  1. Wrap properties under { type: 'object', properties: {...} }.
  2. Move every property where required => true into a top-level required[] string list.
  3. Drop required => false entirely (it was a no-op).
  4. Omit the required key when no properties are required (don't emit empty arrays).
  5. Every type: array property declares an items schema (required by OpenAI strict tool-schema validation, see MEMORY.md). Choices made:
    • step_order, pipelines, steps (workflow steps), flows, flow_configs, updates, requestsitems: { type: object } (arrays of structured objects)
    • disabled_tools, tool_categories, flow_step_ids, types (health-check types) → items: { type: string } (string lists)
    • post_ids (AssignTaxonomyTerm) → items: { type: integer } (post ID list)
  6. All other property keys (description, enum) preserved verbatim.

Required fields summary

  • No required: ListFlows, GetProblemFlows, GetHandlerDefaults, ReadLogs, SystemHealthCheck, CreatePipeline, CreateFlow, ConfigureFlowSteps, ApiQuery (validated at handler level — multiple selection modes)
  • action: ManageQueue, ManageJobs, ManageLogs, AuthenticateHandler
  • flow_id: DeleteFlow, UpdateFlow, RunFlow
  • pipeline_id: DeletePipeline
  • pipeline_id + step_type: AddPipelineStep
  • pipeline_id + pipeline_step_id: DeletePipelineStep
  • pipeline_id + step_order: ReorderPipelineSteps
  • pipeline_step_id: ConfigurePipelineStep
  • source_flow_id + target_pipeline_id + flow_name: CopyFlow
  • webhook_url: SendPing
  • filename: DeleteFile
  • steps: ExecuteWorkflowTool
  • taxonomy: SearchTaxonomyTerms
  • taxonomy + name: CreateTaxonomyTerm
  • term + taxonomy: UpdateTaxonomyTerm
  • term + taxonomy + post_ids: AssignTaxonomyTerm
  • source_term + target_term + taxonomy: MergeTaxonomyTerms
  • handler_slug + defaults: SetHandlerDefaults

Out of scope (intentionally)

Test plan

  • PHP syntax check (php -l) passes on all 31 modified files.
  • homeboy lint --path . --changed-since main returns no findings.
  • Verified zero 'required' => true|false references remain in inc/Api/Chat/Tools/.
  • tests/Unit/Api/Chat/Tools/ListFlowsTest.php (only test in this directory) does not pin schema shape — tests behavior via handle_tool_call, unaffected by parameter schema changes.
  • Live tool calls in production chat post-merge (manual sanity check on a representative subset: list_flows, create_flow, manage_jobs, assign_taxonomy_term).

Constraints honored

  • Branched off main, no commits to main.
  • No CHANGELOG.md edits, no version constant bumps — homeboy owns those.
  • No deploy, no release.
  • Only inc/Api/Chat/Tools/ modified — no Global tools, handler tools, REST API args, settings UI, or Abilities schemas touched.

Convert all 31 chat tool definitions in inc/Api/Chat/Tools/ from the legacy
property-keyed parameter shape to canonical JSON Schema.

DM 0.106.1 PR #1900 ("Require canonical AI tool schemas") removed
RequestBuilder::normalizeToolParameters auto-normalization. Tool registrations
now go to OpenAI as the schema literal, so chat tools that still emit the
legacy {name => {type, required: true|false, description}} shape would fail
provider validation post-0.106.1.

Conversion rules (identical to Extra-Chill/data-machine-events#232):

1. Wrap properties under { type: 'object', properties: {...} }.
2. Move required => true properties into a top-level required[] array.
3. Drop required => false entirely (no-op).
4. Omit required key when no required properties (no empty array).
5. Every type: array property declares an items schema (OpenAI strict mode).
6. Preserve description, enum, and other property keys verbatim.

Closes part of #1921.

Refs: Extra-Chill/data-machine-events#232 (chat tools precedent)
Refs: Extra-Chill/data-machine-events#235 (handler-tool merge precedent)
@homeboy-ci
Copy link
Copy Markdown
Contributor

homeboy-ci Bot commented May 10, 2026

Homeboy Results — data-machine

Lint

lint — passed

ℹ️ Full options: homeboy docs commands/lint
Deep dive: homeboy lint data-machine --changed-since 065ce80

Test

test — passed

  • 1248 passed
  • 3 skipped

ℹ️ Auto-fix lint issues: homeboy refactor data-machine --from lint --write
ℹ️ Collect coverage: homeboy test data-machine --coverage
ℹ️ Save test baseline: homeboy test data-machine --baseline
ℹ️ Pass args to test runner: homeboy test -- [args]
ℹ️ Full options: homeboy docs commands/test
Deep dive: homeboy test data-machine --changed-since 065ce80

Audit

audit — passed

  • test_coverage — 58 finding(s)
  • dead_code — 35 finding(s)
  • intra-method-duplication — 9 finding(s)
  • repeated_literal_shape — 4 finding(s)
  • dead_guard — 2 finding(s)
  • Directives — 1 finding(s)
  • Retention — 1 finding(s)
  • field_patterns — 1 finding(s)
  • parallel-implementation — 1 finding(s)
  • Total: 112 finding(s)

Deep dive: homeboy audit data-machine --changed-since 065ce80

Tooling versions
  • Homeboy CLI: homeboy 0.163.1+2138c225
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: 856e0e3
  • Action: Extra-Chill/homeboy-action@v2

@chubes4 chubes4 merged commit 54224db into main May 10, 2026
3 checks passed
@chubes4 chubes4 deleted the fix-canonical-chat-tools branch May 10, 2026 01:57
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