Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/runtime/provider_codex.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ func (codexProvider) Materialize(ctx *providerMaterializeContext) error {
func (codexProvider) Prepare(in providerInvocation) (CommandSpec, error) {
argv := buildProviderArgs(in)
argv = dropCodexResumeArgs(argv)
// Runs expose tools through the Agent's MCP allowlist, as chat does.
argv = append(argv, "-c", `web_search="disabled"`)
// exec options must precede the `resume` subcommand, so the effort config
// override is appended here rather than after the resume session ID.
if effort := strings.TrimSpace(in.Executor.Effort); effort != "" && !codexHasReasoningEffort(argv) {
Expand Down
16 changes: 16 additions & 0 deletions internal/runtime/provider_gateway_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ func TestNativeProviderCustomGateway(t *testing.T) {
http.Error(w, "bad body", 400)
return
}
unsupportedSearch := false
if kind == "codex" {
tools, _ := body["tools"].([]any)
for _, raw := range tools {
tool, _ := raw.(map[string]any)
toolType, _ := tool["type"].(string)
unsupportedSearch = unsupportedSearch || strings.HasPrefix(toolType, "web_search")
}
}
mu.Lock()
requests++
expectedPath, header := "/v1/responses", r.Header.Get("Authorization")
Expand All @@ -61,7 +70,14 @@ func TestNativeProviderCustomGateway(t *testing.T) {
if r.URL.Path != expectedPath || header != expectedKey || body["model"] != "gateway-test-model" {
wrong = "wrong endpoint, key or model"
}
if unsupportedSearch {
wrong = "unexpected built-in web search tool"
}
mu.Unlock()
if unsupportedSearch {
http.Error(w, "web_search is not supported by this gateway", http.StatusBadRequest)
return
}
w.Header().Set("Content-Type", "text/event-stream")
emit := func(event string, data any) {
raw, _ := json.Marshal(data)
Expand Down
42 changes: 42 additions & 0 deletions internal/runtime/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,48 @@ func TestProvidersBuildFinalArgvWithoutDuplicateManagedFlags(t *testing.T) {
}
}

func TestCodexRunDisablesBuiltinWebSearch(t *testing.T) {
for _, test := range []struct {
name, driver, session string
args []string
}{
{name: "existing executor", driver: "local", args: []string{"exec", "--json"}},
{name: "cached search", driver: "docker", args: []string{"exec", "-c", `web_search="cached"`}},
{name: "live search", driver: "bwrap", args: []string{"exec", "-c", `web_search="live"`}},
{name: "resume", driver: "local", session: "session-123", args: []string{"exec", "resume", "stale"}},
} {
t.Run(test.name, func(t *testing.T) {
command, err := providerForKind("codex").Prepare(providerInvocation{
Executor: domain.ExecutorDefinition{Kind: "codex", Binary: "codex", Args: test.args},
Compiled: compiledConfig{Args: codexConfigArgs("probe", nil, []domain.MCPServerDefinition{
{ID: "docs", Transport: "http", URL: "https://mcp.example/x"},
})},
Prompt: "probe",
Driver: test.driver,
Options: InvocationOptions{ResumeSessionID: test.session},
})
if err != nil {
t.Fatal(err)
}
webSearch := ""
for i, arg := range command.Argv {
if arg == "resume" {
break // Config overrides must precede this subcommand.
}
if arg == "-c" && i+1 < len(command.Argv) && strings.HasPrefix(command.Argv[i+1], "web_search=") {
webSearch = command.Argv[i+1]
}
}
if webSearch != `web_search="disabled"` {
t.Fatalf("effective web search config = %q in %v", webSearch, command.Argv)
}
if !hasContiguousArgs(command.Argv, []string{"-c", `mcp_servers.docs.url="https://mcp.example/x"`}) || command.Argv[len(command.Argv)-1] != "probe" {
t.Fatalf("MCP configuration or prompt was lost: %v", command.Argv)
}
})
}
}

func TestCodeBuddyPluginDirectoryCannotConsumePrompt(t *testing.T) {
command, err := providerForKind("codebuddy").Prepare(providerInvocation{
Executor: domain.ExecutorDefinition{Kind: "codebuddy", Binary: "codebuddy"},
Expand Down