Skip to content

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

Closed
cmarguta-alg wants to merge 4 commits into
algolia:mainfrom
cmarguta-alg:lw-oct-agent-studio-1
Closed

cmarguta-alg wants to merge 4 commits into
algolia:mainfrom
cmarguta-alg:lw-oct-agent-studio-1

Conversation

@cmarguta-alg

@cmarguta-alg cmarguta-alg commented Oct 15, 2026 •

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.

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>
@codacy-production

codacy-production Bot commented Oct 15, 2026 •

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.

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>
@cmarguta-alg cmarguta-alg changed the title feat(agents): add Agent Studio agent commands via official SDK feat(agentstudio): add agents commands via official SDK Oct 15, 2026
cmarguta-alg and others added 2 commits October 15, 2026 16:50
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>
@cmarguta-alg

Copy link
Copy Markdown
Contributor Author

Personal QA Agent — retest after e23d4dc

Verdict: merge-ready, with one environment skip noted below.

Retested commit e23d4dc (fix(agents): document publish needs provider/model and use UUID examples) against app VUX4PAGOPD (--application-id; the currently selected app devYMAVA59HLQ still does not resolve).

What changed since the last run

The previous blockers were documentation/contract mismatches, not command bugs. This commit and the updated PR body now match the live API:

  • Flag create is a draft (providerId: null). publish is expected to 409.
  • Help examples use UUID-shaped IDs, not agt_1 / prv_123.
  • publish --help states 409 unless the agent has a provider and a model.

Executed

Check Result
task build Pass
go test ./pkg/cmd/agentstudio ./pkg/cmd/agents/... ./pkg/cmd/factory ./pkg/cmd/root -count=1 Pass
Help tree + UUID examples; publish --help mentions 409 Pass
Scenario 1 — flag create → list/get → publish Pass: draft created; publish 409 Cannot publish an agent without a model or provider
Scenario 2 (partial) — --json create + patch of name/instructions/description Pass
--json with a non-existent providerId Pass: 422 Provider with ID … not found (no leftover agent)
Scenario 3 — delete without --confirm in non-TTY, then --confirm Pass; subsequent get is 404
Flag --name update, -o jsonpath, get of unknown UUID Pass
Shell completion for agentstudio / agents Pass (from prior run; command surface unchanged)

QA-created agents were deleted. Pre-existing renamed-bot on this app was left untouched.

Skip (environment, not a CLI defect)

Scenario 2 publish/unpublish with a real provider was not live-tested. ListProviders on VUX4PAGOPD returns 0 providers. This slice has no providers command, and inventing a UUID is correctly rejected with 422. Happy-path status: "published" → unpublish → draft still needs an app that already has a provider UUID.

Non-blocking nits (do not hold the merge)

  • TTY create prints ✓ Created agent <id> then JSON on stdout; non-TTY is clean JSON.
  • Flag errors print the root usage tree, not the subcommand’s flags.
  • update --json '{}' is a successful no-op PATCH.
  • -o jsonl on list emits one object (the page), not one agent per line.
  • Interactive delete prompt was not exercised (this environment is non-TTY). --confirm / -y were.

— Personal QA Agent

@cmarguta-alg

Copy link
Copy Markdown
Contributor Author

Moved to a same-repo PR on algolia/cli: #289 (head algolia:lw-oct-agent-studio-1, not the fork).

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