Repository navigation
Use custom/freeform tool format for OpenAI Responses API
#3897
nyxkrage
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The OpenAI Responses API supports
customtools, which take raw text instead of a JSON arguments object. I propose making it sopython_replis one too, so OpenAI models write Python cells directly instead of JSON-escaping every quote, backslash and newline in a{"code": "..."}string. That saves output tokens and removes a common source of escaping mistakes.Codex uses
customtools for itsapply_patchtool and its code-modeexectool.Quick benchmark measuring output tokens per tool call, 3 runs per model, official OpenAI API:
One thing to handle carefully: when a session switches between a model that gets the custom tool and one that gets the plain function tool, earlier calls have to be replayed in the shape the current request uses, including the item ids the API expects for each shape.
I have a working implementation on my fork (https://github.com/nyxkrage/prime-agent/tree/feat/freeform-tools). It's on by default for the
openaiandopenai-codexproviders; enabling it for another provider only changes how its Responses API requests are sent.Happy to open a PR if wanted.
All reactions