Skip to content

feat(agentstudio): support explicit local and review routing - #302

Open
leonardocuco wants to merge 2 commits into
mainfrom
feat/cec-1883-agent-studio-routing
Open

leonardocuco wants to merge 2 commits into
mainfrom
feat/cec-1883-agent-studio-routing

Conversation

@leonardocuco

@leonardocuco leonardocuco commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Agent Studio SDK uses /agent-studio/1/... paths and the CLI cannot target a local or review backend. A host-only override would send the wrong paths to the direct API and could leave the existing Search ACL preflight pointed at an unexpected environment.

Change

  • Add agentstudio --base-url for an explicit HTTPS endpoint or loopback HTTP endpoint. Its path replaces the SDK's /agent-studio prefix, supporting both direct /1/... routes and a proxy prefix.
  • Keep the existing Search ACL preflight. When a base URL is supplied, require explicit valid --search-hosts, reject conflicts with ALGOLIA_SEARCH_HOSTS, and fail before a request for malformed or ambiguous destinations. Both endpoints receive the configured credentials.
  • Reject URL credentials and redirects, prohibit non-loopback HTTP, prevent an empty override from falling back to production, and redact API keys from override-path and preflight errors.
  • Cover agents, providers and conversations, ACL preflight, 403 responses, redirects, key redaction, defaults, and the complete CLI invocation with mocked/local servers.

The inspected local backend snapshot enforces route-specific ACLs: agent and provider configuration routes check settings/editSettings and conversation operations check logs (or the secured-token path). The CLI preflight remains in place; this PR does not claim that a particular review or production deployment has been verified.

Verification

  • go generate ./...
  • go test ./...
  • go build ./...
  • git diff --cached --check

Related to CEC-1883. No release or deployment during the code freeze. A live-environment check remains for CEC-1890 after the freeze.

Leonardo Cuco and others added 2 commits November 30, 2026 17:14
@leonardocuco
leonardocuco marked this pull request as ready for review November 30, 2026 17:23
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 30, 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-30T17:25:18.677455Z af26c4c Draft marked ready
ℹ️ 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.

@leonardocuco

Copy link
Copy Markdown
Contributor Author

Claude Code wrote this comment. Claude Code reviewed this change at af26c4c for the author: 9 findings, 3 fixed, 1 not a bug, 5 left.

  • pkg/cmd/factory/agent_studio_route.go:47: network errors lost their type, so the SDK could not recognise timeouts or cancellation. Fixed in 3313c00.
  • pkg/cmd/factory/agent_studio_route.go:41: rewritten paths dropped percent-encoding (an ID containing an encoded slash). Fixed in 3313c00.
  • pkg/cmd/factory/agent_studio_route.go:50: error bodies were read without a size limit and Content-Length was stale after redaction. Fixed in 3313c00.
  • pkg/cmd/factory/agent_studio_route.go:26: timeouts reported as ignored. Not a bug: the SDK transport applies a per-request context timeout, which the cloned request keeps.
  • pkg/cmd/factory/agent_studio_route.go:31: a redirect surfaces as a generic status error with no hint. Left: minor, the redirect is rejected as intended.
  • pkg/auth/auth_check.go:177: a trailing slash in --search-hosts is rejected. Left: minor.
  • pkg/auth/auth_check.go:126: validation errors do not use FlagErrorf. Left: convention nit.
  • pkg/cmd/agentstudio/routing_integration_test.go:3: import grouping and long lines. Left: style nit.
  • pkg/cmdutil/agent_studio_url.go:20: the localhost check is case-sensitive and the message is terse. Left: minor.

Tests, vet and gofmt pass for the changed package.

@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: af26c4c01b

ℹ️ 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 on lines +25 to +26
func (r agentStudioHTTPClient) Request(req *http.Request, _, _ time.Duration) (*http.Response, error) {
return r.client.Do(req)

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 Preserve request timeouts in the custom HTTP requester

When a local or review backend accepts a connection but stalls while serving a response, this adapter discards both timeout arguments supplied by the SDK and calls http.Client.Do without applying them. The Agent Studio command handlers do not attach their own context deadlines, so override requests no longer respect the SDK's per-attempt timeout settings and can hang instead of failing promptly. Preserve the SDK request and connection timeout handling while disabling redirects.

Useful? React with 👍 / 👎.

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