Skip to content

fix(chatgpt-subscription): support Responses API tool calling#5490

Open
donk4488 wants to merge 2 commits into
odysseus-dev:devfrom
donk4488:fix/chatgpt-subscription-tools
Open

fix(chatgpt-subscription): support Responses API tool calling#5490
donk4488 wants to merge 2 commits into
odysseus-dev:devfrom
donk4488:fix/chatgpt-subscription-tools

Conversation

@donk4488

@donk4488 donk4488 commented Jul 12, 2026

Copy link
Copy Markdown

Summary

Adds native Odysseus tool-calling support for ChatGPT Subscription models using the Codex Responses backend. Previously, the agent loop selected tools but the ChatGPT Subscription adapter did not include them in outbound requests, parse streamed function calls, or preserve structural tool-call history across rounds. This change implements Responses-compatible tool serialization, streamed function-call parsing, exact call_id preservation, function_call_output replay, parallel tool calls, and encrypted reasoning continuity.

Target branch

  • This PR targets dev, not main. All PRs land in dev; main is curated by the maintainer at each release. If your PR is on main by accident, click "Edit" on this PR and change the base.

Linked Issue

Part of #[#199]

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)
  • New feature (non-breaking — adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

How to Test

  1. Configure and authenticate a ChatGPT Subscription endpoint, then confirm that the endpoint has supports_tools=True.

  2. Start Odysseus:

    python -m uvicorn app:app --host 127.0.0.1 --port 7000
  3. Open a fresh agent-mode conversation using a ChatGPT Subscription/Codex model and send:

    Call get_workspace and return its exact result.
    
  4. Confirm the logs show that tools were sent and executed:

    _is_api_model=True
    tools_sent > 0
    native_tools=True
    Agent round 1: received 1 native tool call(s)
    Tool executed: get_workspace
    
  5. Test a multi-round tool sequence:

    Call get_workspace, then read C:\odysseus\README.md and return only its first Markdown heading.
    
  6. Confirm that the model calls get_workspace, then read_file, and finally returns the heading from the actual file. In the tested environment, the final response was:

    ## Quick Start
    
  7. Run the focused test suite:

    python -m pytest tests/test_chatgpt_subscription_tools.py -q

    Expected result:

    9 passed
    
  8. Run syntax validation:

    python -m py_compile src/chatgpt_subscription.py
    python -m py_compile src/llm_core.py
    python -m py_compile routes/chatgpt_subscription_routes.py

Implementation Notes

  • Converts Odysseus/OpenAI Chat Completions-style function schemas into the flattened Responses tool format.
  • Includes selected tools and tool-choice configuration in ChatGPT Subscription requests.
  • Parses streamed Responses function-call events and aggregates argument deltas.
  • Normalizes completed calls into Odysseus’s existing native tool_calls event structure.
  • Preserves exact function call_id values across model and tool-result rounds.
  • Converts tool results into structural function_call_output items.
  • Supports multiple and parallel function calls.
  • Requests and replays encrypted reasoning items for stateless store=false tool rounds.
  • Prevents model-specific encrypted reasoning data from being replayed to incompatible models.
  • Provisions new ChatGPT Subscription endpoints with supports_tools=True.
  • Does not change src/agent_loop.py or bypass existing tool authorization and confirmation logic.

Visual / UI changes — REQUIRED if you touched anything that renders

This PR does not modify UI rendering, CSS, HTML, SVG, visual components, or static/js/ DOM behavior.

  • Screenshot or short clip of the change in the running app, attached below. Mobile screenshot too if the change affects mobile.
    Not applicable — no visual or UI changes.

  • Style match: the change uses Odysseus's existing visual language. Specifically:

    • Reuse existing CSS variables (--red, --fg, --bg, --card, --border, etc.) — do not introduce new color values, font sizes, or spacing units.
    • Reuse existing button/input/card/border classes. Don't invent parallel styling.
    • No Unicode emoji in UI or code. Use inline SVG (matching the monochrome icon style already in static/index.html) or plain text.
    • Monospaced font (Fira Code) for primary UI text. Don't override.
    • Dark theme is the default; any light-mode work must be wired through the existing theme system, not hard-coded.

    Not applicable — no UI or styling files were changed.

  • No new component patterns. If a similar widget already exists in the app, extend it instead of writing a parallel one.
    Not applicable — no components were added or modified.

  • I am not an LLM agent submitting a bulk PR. If you are, please open an issue describing the problem first — bulk auto-generated PRs that don't match the project's visual style are closed on sight, even when the underlying fix is correct.

Screenshots / clips

Not applicable — this is a provider-layer change with no visual or UI modifications.

@github-actions github-actions Bot added needs work PR description incomplete — please update before review ready for review Description complete — ready for maintainer review and removed needs work PR description incomplete — please update before review labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant