Skip to content

feat(agentstudio): add agents commands via official SDK - #289

Merged
cmarguta-alg merged 5 commits into
mainfrom
lw-oct-agent-studio-1
Oct 16, 2026
Merged

cmarguta-alg merged 5 commits into
mainfrom
lw-oct-agent-studio-1

Conversation

@cmarguta-alg

Copy link
Copy Markdown
Contributor

🤔 What

Adds algolia agentstudio agents so you can list, get, create, update, delete, publish, and unpublish Agent Studio agents through the official Go SDK.

🤷 Why

#212 covered the full Agent Studio API with a custom api/agentstudio client and was too large to review. This PR is the Agents resource only, using algoliasearch-client-go (already a CLI dependency) so the slice can merge. agentstudio is the product slug so later modules (conversations, providers) can sit beside agents.

🔍 How

Section Group Change
SDK Bump algoliasearch-client-go from v4.43.1 to v4.48.0.
Factory Add AgentStudioClient beside CompositionClient (app ID, API key, CLI user agent).
Commands Register algolia agentstudio agents with list/get/create/update/delete/publish/unpublish calling the matching SDK methods.
Input create/update take --name/--instructions or an inline --json object; no file reads. delete requires --confirm off TTY.

Flag create is a draft with no provider. The API returns 409 on publish until the agent has providerId and model (set via --json). This PR does not list providers.

🧪 Testing

Reads need an API key with settings. Writes need editSettings. Replace <APP_ID> with an app that has Agent Studio. If the selected profile app does not resolve, pass --application-id — ACL lookup runs first. Replace <provider-id> with a provider UUID from the Agent Studio dashboard (or from get on an existing agent). Agent IDs are UUIDs.

Quick checks

task build
go test ./pkg/cmd/agentstudio ./pkg/cmd/agents/... ./pkg/cmd/factory ./pkg/cmd/root -count=1
./algolia agentstudio --help
./algolia agentstudio agents --help
./algolia agentstudio agents publish --help

Expect tests green, a fresh ./algolia binary, agentstudio on the root command, and agents with subcommands list, get, create, update, delete, publish, unpublish. publish --help states 409 without provider/model. Examples use UUID-shaped IDs, not agt_1.

Scenario 1 — flag-based draft

Action: create from flags, then list/get, then publish.

./algolia agentstudio agents create --application-id <APP_ID> \
  --name "cli-test-agent" \
  --instructions "You are a helpful assistant."

./algolia agentstudio agents list --application-id <APP_ID> --page 1 --limit 20
./algolia agentstudio agents get <agent-id> --application-id <APP_ID>
./algolia agentstudio agents publish <agent-id> --application-id <APP_ID>

Expectation: create prints JSON with id, status: "draft", and providerId: null. list includes that agent (pagination.page/limit are 1/20). get matches the same id. publish fails with 409 Cannot publish an agent without a model or provider.

Scenario 2 — --json with provider, then publish

Action: create with providerId and model, update, publish, unpublish.

./algolia agentstudio agents create --application-id <APP_ID> --json '{
  "name": "cli-json-agent",
  "instructions": "You are a helpful assistant.",
  "description": "Created from a JSON string",
  "providerId": "<provider-id>",
  "model": "gpt-4o"
}'

./algolia agentstudio agents update <agent-id> --application-id <APP_ID> --json '{
  "name": "cli-json-agent-renamed",
  "instructions": "Be brief.",
  "description": "Patched from a JSON string"
}'

./algolia agentstudio agents get <agent-id> --application-id <APP_ID>
./algolia agentstudio agents publish <agent-id> --application-id <APP_ID>
./algolia agentstudio agents unpublish <agent-id> --application-id <APP_ID>

Expectation: create stores name, instructions, description, providerId, and model. update PATCH-es the text fields; get shows the new name. publish returns status: "published"; unpublish returns draft.

Scenario 3 — delete confirmation (failure mode)

Action: delete without --confirm in a non-TTY, then with --confirm.

./algolia agentstudio agents delete <agent-id> --application-id <APP_ID>
./algolia agentstudio agents delete <agent-id> --application-id <APP_ID> --confirm
./algolia agentstudio agents get <agent-id> --application-id <APP_ID>

Expectation: the first command errors with --confirm required when non-interactive shell is detected and the agent still exists. The second exits 0. get then fails because the agent is gone.

⚠️ Dependencies

  • This PR bumps algoliasearch-client-go to v4.48.0.
  • Target application must have Agent Studio. No new environment variables.
  • Publish needs a provider UUID from the dashboard; providers is a later module.
  • The SDK does not expose DuplicateAgent; that endpoint is out of scope.

Made with Cursor

cmarguta-alg and others added 4 commits October 15, 2026 15:56
Expose list/get/create/update/delete/publish/unpublish on algolia agents
using algoliasearch-client-go v4.48.0 instead of a custom HTTP client.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use algolia agentstudio agents as the product slug, and pass create/update
bodies as JSON strings instead of files.

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid gosec G115 int-to-int32 conversions that failed CI lint.

Co-authored-by: Cursor <cursoragent@cursor.com>
Help copied agt_1/prv_123 which the API rejects as 422, and flag create
cannot be published. Point examples at UUID placeholders and the --json
providerId+model path.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 101 complexity · 53 duplication

Metric Results
Complexity 101
Duplication 53

View in Codacy

TIP This summary will be updated as you push new changes.

@cmarguta-alg
cmarguta-alg requested a review from tkrugg October 15, 2026 14:25
CI lint timed out on a cold cache with the default 1m limit.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cmarguta-alg

cmarguta-alg commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Status: 🟢 pass · 🔴 fail · 🟡 inconclusive (unable to test full functionality due to missing required data)

Personal QA Agent — retest of #289 with a real provider

Verdict: merge-ready. Previously 🟡 publish/unpublish is now 🟢.

Retested the agents command surface (from the stacked lw-oct-agent-studio-3 tree, which includes these commands) on app VUX4PAGOPD using provider 80e4966a-0c4a-47e6-967d-2375c7bace94 (Anthropic / anthropic), model claude-sonnet-5-5. The provider was not deleted.

Results

Check Status Notes
task build / unit tests (prior run) 🟢 Unchanged
Help tree + UUID examples; publish --help mentions 409 🟢 Prior run
Scenario 1 flag create → list/get → publish without provider 🟢 Draft; publish 409 (matches spec) — prior run
Scenario 2 --json create + patch of name/instructions/description 🟢 Prior + this run
Scenario 2 --json create with real providerId + model, then publish / unpublish 🟢 Create status: draft with providerId set. publish → published. unpublish → draft. Re-publish also 🟢
--json with a non-existent providerId 🟢 422 — prior run
Scenario 3 delete without --confirm in non-TTY, then --confirm 🟢 Prior run; this run also deleted the QA agent with --confirm
Interactive delete prompt 🟡 Non-TTY; --confirm / -y tested

QA agent d40699ad-8042-49ee-9588-c8fb07a617de was deleted after the retest. Provider left in place. Pre-existing renamed-bot untouched.

Non-blocking nits (unchanged)

  • TTY create prints ✓ Created agent <id> then JSON; non-TTY is clean JSON.
  • Flag errors print the root usage tree.
  • update --json '{}' is a successful no-op PATCH.
  • -o jsonl on list emits one object (the page).

— Personal QA Agent

@cmarguta-alg
cmarguta-alg merged commit c52acf7 into main Oct 16, 2026
3 of 4 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.

2 participants