Skip to content

Use model composition for runtime LLM and service selection - #2178

Merged
asim merged 3 commits into
mainfrom
model-selection
Nov 13, 2026
Merged

asim merged 3 commits into
mainfrom
model-selection

Conversation

@asim

@asim asim commented Nov 13, 2026

Copy link
Copy Markdown
Member

The model composition now drives agent and writing prompts, LLM selection and agent service availability. Callers can supply a Definition; existing run-level model IDs remain overrides. Explicit providers use runtime credentials and fail instead of silently switching providers. Both streaming and non-streaming writing use the same composition.

Service selection intersects the composition with permitted services and agent scopes; an explicit empty list disables tools, while nil inherits availability. Restricted compositions also retain restricted-caller guards. Named chats now carry the saved agent LLM choice, which was previously omitted.

Storage remains with agent records; internal/model composes definitions and does not add a model store. Knowledge references continue through existing retrieval services.

Validation includes real HTTP adapter tests for composed prompts and selected model IDs in Ask/AskStream, fail-closed provider selection, agent selection and service-scope tests, plus existing model and agent tests. Full CI covers backend, browser, race and release checks.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T10:31:47.968767Z 65406eb Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0703e20bc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agent/native.go Outdated
composition := composedModel(opts)
if composition.LLM.Provider != "" {
p, k, id, base, err := model.ResolveLLM(composition.LLM, opts.Public)
return p, k, id, base, err == nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize explicit-provider base URLs before building the agent

When a composition explicitly selects openai and OPENAI_BASE_URL includes the documented /v1 suffix, ResolveLLM returns that URL unchanged, and buildNativeAgent passes it directly to gmagent.BaseURL. The provider appends /v1/chat/completions, producing /v1/v1/chat/completions and causing agent requests to fail. The existing nativeLLMFor paths already apply model.ProviderBaseURL for this reason (see internal/model/baseurl.go); apply the same conversion to this new path.

Useful? React with 👍 / 👎.

asim commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

@codex review
Fixed explicit-provider URL normalization via ProviderBaseURL in nativeModelForAccount. Added regression assertion for OPENAI_BASE_URL ending in /v1. Please review the updated head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80bc5597f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agent/native.go
Comment on lines +870 to +872
func selectedServices(opts QueryOpts, available []string) []string {
available = composedModel(opts).SelectServices(available)
available = filterServices(available, opts.Tools)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Apply composition restrictions to management tools

For a signed-in account with opts.Tools unset, setting Definition.Services to an empty or restricted list only filters the discovered service tools. buildNativeAgent still appends managementTools(accountID, opts), whose guard in agent/manage.go checks only NoTools, Public, and opts.Tools. Consequently, an explicitly tool-free composition still exposes micro_agents and the mutating micro_create_agent, and scoped compositions receive management capabilities that existing scoped specialists do not. Make the management-tool guard honor composition restrictions as well.

Useful? React with 👍 / 👎.

asim commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

@codex review
Management tools now reject compositions with an explicit service scope, including an empty list. Regression tests cover scoped and tool-free compositions without opts.Tools. Both prior findings are addressed.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 65406eb745

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@asim
asim merged commit f62a435 into main Nov 13, 2026
3 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.

1 participant