Repository navigation
feat(agentstudio): add agents commands via official SDK - #286
cmarguta-alg wants to merge 4 commits into
Conversation
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>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 101 |
| Duplication | 53 |
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>
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>
Personal QA Agent — retest after
|
| 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
createprints✓ 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 jsonlonlistemits one object (the page), not one agent per line.- Interactive delete prompt was not exercised (this environment is non-TTY).
--confirm/-ywere.
— Personal QA Agent
|
Moved to a same-repo PR on algolia/cli: #289 (head |
🤔 What
Adds
algolia agentstudio agentsso 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/agentstudioclient and was too large to review. This PR is the Agents resource only, usingalgoliasearch-client-go(already a CLI dependency) so the slice can merge.agentstudiois the product slug so later modules (conversations, providers) can sit besideagents.🔍 How
algoliasearch-client-gofrom v4.43.1 to v4.48.0.AgentStudioClientbesideCompositionClient(app ID, API key, CLI user agent).algolia agentstudio agentswith list/get/create/update/delete/publish/unpublish calling the matching SDK methods.create/updatetake--name/--instructionsor an inline--jsonobject; no file reads.deleterequires--confirmoff TTY.Flag create is a draft with no provider. The API returns 409 on
publishuntil the agent hasproviderIdandmodel(set via--json). This PR does not list providers.🧪 Testing
Reads need an API key with
settings. Writes neededitSettings. 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 fromgeton 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 --helpExpect tests green, a fresh
./algoliabinary,agentstudioon the root command, andagentswith subcommandslist,get,create,update,delete,publish,unpublish.publish --helpstates 409 without provider/model. Examples use UUID-shaped IDs, notagt_1.Scenario 1 — flag-based draft
Action: create from flags, then list/get, then publish.
Expectation:
createprints JSON withid,status: "draft", andproviderId: null.listincludes that agent (pagination.page/limitare1/20).getmatches the sameid.publishfails with 409Cannot publish an agent without a model or provider.Scenario 2 —
--jsonwith provider, then publishAction: create with
providerIdandmodel, update, publish, unpublish.Expectation: create stores name, instructions, description,
providerId, andmodel. update PATCH-es the text fields;getshows the new name.publishreturnsstatus: "published";unpublishreturnsdraft.Scenario 3 — delete confirmation (failure mode)
Action: delete without
--confirmin a non-TTY, then with--confirm.Expectation: the first command errors with
--confirm required when non-interactive shell is detectedand the agent still exists. The second exits 0.getthen fails because the agent is gone.algoliasearch-client-goto v4.48.0.providersis a later module.DuplicateAgent; that endpoint is out of scope.