Skip to content

Name conversations on the endpoint OPENAI_BASE_URL names, not on OpenAI - #556

Merged
davidmckayv merged 2 commits into
CopilotKit:mainfrom
zopeVaibhav:fix/titler-openai-base-url
Sep 15, 2026
Merged

davidmckayv merged 2 commits into
CopilotKit:mainfrom
zopeVaibhav:fix/titler-openai-base-url

Conversation

@zopeVaibhav

Copy link
Copy Markdown
Contributor

Fixes #555

What this changes

The titler that names conversations built its address from a hardcoded https://api.openai.com/v1, and its only caller never passed a base URL, so it ignored OPENAI_BASE_URL while the router and tool selection honoured it. A deployment behind a gateway sent the gateway's key and each conversation's opening to OpenAI, and no conversation was named.

It now asks chatCompletionsUrl in routing/model.ts, the function those calls already use, so the three cannot disagree about where the deployment's model is, and that function's existing /v1 handling applies here too. The unused baseUrl option becomes an optional environment, defaulting to process.env and read on each call as the router reads it, so a test can drive it without changing the process.

Left alone: the request body, including max_completion_tokens, and the key resolver.

Where it runs

  • New state that outlives a request? No. The address is read from the environment on each call.
  • What happens on the second replica? It reads the same environment and asks the same address.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No. The naming loop and its cadence are unchanged.

Boundary and audit

No acting call, refusal or audit row changes. What leaves the deployment narrows: with OPENAI_BASE_URL set, the titler's key and excerpt now go to that endpoint and nowhere else.

Changelog

A line under Unreleased.

Proof

  • server/tests/channel-titler.test.ts gains two tests. An environment naming https://gateway.internal/v1 is asked at https://gateway.internal/v1/chat/completions, and with no environment passed, the titler reads OPENAI_BASE_URL from the process, which is how index.ts builds it. Against main's titler.ts (a96d88c) both fail, each receiving https://api.openai.com/v1/chat/completions, and the other 5 pass. On this branch all 7 pass. The existing default test now passes environment: {} so a developer's own OPENAI_BASE_URL cannot change its answer.
  • A script building createModelCompleter and createChannelTitler with the arguments index.ts gives them, OPENAI_BASE_URL at a local fake gateway and off-box fetch intercepted. On main the router reached the gateway and the titler went to api.openai.com with the gateway's key and the excerpt. On this branch both reached the gateway and nothing left the box.
  • Full server suite against a migrated openbot_test: 2481 pass on main, 2483 on this branch, 0 failures on either. The difference is the two new tests.
  • bun run --filter server typecheck and biome lint --error-on-warnings on both files: clean.
  • The naming loop in a running API server, against a local conversation with a real transcript whose name was cleared, with OPENAI_BASE_URL pointed at a local proxy that forwards to OpenAI and logs each request. On main the conversation was named within seconds and the proxy logged no request at all, so the naming call went to OpenAI directly. On this branch the proxy logged POST /v1/chat/completions with model=gpt-5.5, the naming instruction in the body and a 200, and the conversation was named from that answer.

@zopeVaibhav
zopeVaibhav force-pushed the fix/titler-openai-base-url branch 2 times, most recently from eb1a770 to cfdeb82 Compare September 15, 2026 16:38
@zopeVaibhav
zopeVaibhav force-pushed the fix/titler-openai-base-url branch from cfdeb82 to 8185db3 Compare September 15, 2026 16:44

@davidmckayv davidmckayv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code-verified clean; CI green on this sha.

@davidmckayv
davidmckayv merged commit d496dfa into CopilotKit:main Sep 15, 2026
15 checks passed
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.

Naming a conversation sends its request to api.openai.com whatever OPENAI_BASE_URL says

2 participants