Skip to content

Conversation

@SamMorrowDrums
Copy link
Collaborator

@SamMorrowDrums SamMorrowDrums commented Dec 8, 2025

Closes #1553

Summary

OpenAI strict mode requires the properties field to be present in object schemas, even when empty. The get_me tool has no input parameters, so its schema was {"type": "object"} without a properties field.

Problem

The jsonschema library's Schema struct uses omitempty JSON tags, causing empty maps to be omitted during JSON serialization. Even when setting Properties: map[string]*jsonschema.Schema{}, the output remains {"type": "object"}.

Error from OpenAI:

Error code: 400 - {'error': {'message': "Invalid schema for function 'get_me': In context=(), object schema missing properties.", 'type': 'invalid_request_error', 'param': 'tools[13].function.parameters', 'code': 'invalid_function_parameters'}}

Solution

Use json.RawMessage to bypass the library's serialization and explicitly include "properties": {} in the output:

InputSchema: json.RawMessage(`{"type":"object","properties":{}}`)

This ensures OpenAI strict mode compatibility while maintaining the same logical schema.

Testing

  • script/lint - 0 issues
  • script/test - all tests pass
  • ✅ Toolsnap updated to reflect new schema with "properties": {}

Fixes #1548

OpenAI strict mode requires the `properties` field to be present in
object schemas, even when empty. The jsonschema library uses omitempty
which causes empty maps to be omitted during JSON serialization.

This change uses json.RawMessage to bypass the library's serialization
and explicitly include `"properties": {}` in the output.

Fixes #1548
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner December 8, 2025 10:03
Copilot AI review requested due to automatic review settings December 8, 2025 10:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an OpenAI strict mode compatibility issue where the get_me tool's input schema lacked an explicit properties field. OpenAI's strict mode requires object schemas to include the properties field even when empty, but the jsonschema library omits empty maps during serialization due to omitempty tags.

Key Changes

  • Modified get_me tool to use json.RawMessage for explicit schema control
  • Updated toolsnap to reflect the new schema with empty properties object

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/github/context_tools.go Changed InputSchema from &jsonschema.Schema{Type: "object"} to json.RawMessage with explicit "properties": {} to ensure OpenAI strict mode compatibility
pkg/github/toolsnaps/get_me.snap Updated snapshot to reflect the new schema format including the empty properties field

@SamMorrowDrums SamMorrowDrums merged commit 82c4930 into main Dec 8, 2025
22 checks passed
@SamMorrowDrums SamMorrowDrums deleted the fix-openai-get-me-schema branch December 8, 2025 10:15
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.

Openai models 4 and above don't work with the current 0.24.0 version

3 participants