Repository navigation
feat(agentstudio): accept --file for JSON payloads - #291
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 21 |
| Duplication | 49 |
TIP This summary will be updated as you push new changes.
|
Status: 🟢 pass · 🔴 fail · 🟡 inconclusive Personal QA Agent — #291 (
|
| Entity | SDK type | Fields |
|---|---|---|
| Agent create | AgentConfigCreate |
name, description, providerId, model, instructions, systemPrompt, templateType, config, tools |
| Agent update | AgentConfigUpdate |
same, nullable |
| Provider create | ProviderAuthenticationCreate |
name, providerName, input |
Provider input |
ProviderInput oneOf |
openai/anthropic/xai: apiKey+baseUrl; azure: apiKey+azureEndpoint+azureDeployment+apiVersion; openai_compatible: apiKey+baseUrl+defaultModel; google_genai/deepseek: apiKey |
| Provider update | ProviderAuthenticationPatch |
name and/or input |
| Tools | ToolConfigInput |
algolia_search_index, client_side, mcp_tools, algolia_recommend |
Round-trip (unmarshal → marshal, same path as --file) and live API:
| Payload | Status | Notes |
|---|---|---|
| Agent: name, description, instructions, systemPrompt, templateType, config, tools | 🟢 | Live: description/systemPrompt/config/templateType persisted. Tools: client_side, algolia_search_index, mcp_tools, algolia_recommend all stored |
Provider openai/anthropic/xai apiKey (+ optional baseUrl) |
🟢 round-trip | Live create 🟡 dummy key → API 422 Invalid API key provided. File reached the API |
Provider azure_openai extra input |
🔴 | File/json azureEndpoint+azureDeployment+apiVersion marshal down to {"apiKey":"…"} only. Live 422 body.azureEndpoint: Field required |
Provider openai_compatible defaultModel |
🔴 | Round-trip drops defaultModel. Live 422 body.defaultModel: Field required |
Cause: generated ProviderInput.UnmarshalJSON fills several oneOf variants at once; MarshalJSON emits Anthropic first, which only has apiKey/baseUrl. --file is not a thinner DTO — it is this SDK type.
Preferred CLI fix: send the file/--json bytes as the request body instead of round-tripping through ProviderAuthenticationCreate / ProviderInput. Validation of name / providerName / input present can stay.
Results
| Check | Status | Notes |
|---|---|---|
task build |
🟢 | |
go test ./pkg/cmdutil ./pkg/cmd/agents/create,update ./pkg/cmd/providers/create,update -count=1 |
🟢 | |
Help documents --file / -f beside --json |
🟢 | agents+providers create/update |
Scenario 1 agents create --file |
🟢 | cli-file-agent id 0b3baef5-… |
Scenario 1 agents create --file - (stdin) |
🟢 | id 353e4820-… |
Scenario 2 providers create --file with dummy key |
🟡 | 422 Invalid API key (same as #290). No live update |
Scenario 3 --json + --file |
🟢 | --json cannot be combined with --file |
Scenario 3 --file + --name |
🟢 | agents and providers |
| Missing file | 🟢 | reading file: open … no such file |
| Invalid JSON file | 🟢 | parsing agent JSON |
Agent update --file (description, instructions, systemPrompt, config, tools) |
🟢 | |
Flag-only agent create (--name + --instructions) |
🟢 | still limited to those two fields; full surface is --file/--json only, as designed |
Notes (not extra 🔴)
allowUnlistedIndices: trueon a search tool 422 unlessmodeisdynamic— API validation; CLI sent the field.- MCP
transport: "sse"422; acceptedstreamable_http. - Recommend tool without
modelName: SDK injects""and API 422. WithmodelName: "related-products"it stored. --jsonhas the same azure / openai_compatible drop (confirmed live).
— Personal QA Agent
9af388a to
aedbc84
Compare
aedbc84 to
e52dbcb
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Explicitly selected empty or whitespace-only file/stdin input bypasses JSON validation and produces empty provider or agent requests in three command paths.
1 open issue
What changed in this PR
Extends Agent Studio agent and provider create/update commands with file and stdin payload input, preserving inline --json support.
Changes:
- Adds
--file/-f, with-for stdin, and updates help examples. - Introduces a shared payload reader with whitespace trimming and source-conflict validation.
- Adds file-input, stdin, and conflicting-flag tests.
| File | Description |
|---|---|
pkg/cmdutil/file_input.go |
Adds the shared JSONPayload reader. |
pkg/cmdutil/file_input_test.go |
Tests payload sources, trimming, conflicts, and missing files. |
pkg/cmd/providers/update/update.go |
Adds file-based provider patches. |
pkg/cmd/providers/update/update_test.go |
Tests file patches and source conflicts. |
pkg/cmd/providers/create/create.go |
Adds file-based provider creation. |
pkg/cmd/providers/create/create_test.go |
Tests file and stdin creation and source conflicts. |
pkg/cmd/agents/update/update.go |
Adds file-based agent patches. |
pkg/cmd/agents/update/update_test.go |
Tests file patches and updated input validation. |
pkg/cmd/agents/create/create.go |
Adds file and stdin input with usage examples. |
pkg/cmd/agents/create/create_test.go |
Tests file and stdin creation and updated input validation. |
Review effort: Balanced
[Medium impact] The changes reach four Agent Studio create and update commands. Reject empty file contents before merging so a missing JSON payload cannot send an unintended update.
|
Let create/update take a JSON file or stdin in addition to inline --json so large or secret-bearing bodies do not have to live on the argv. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…/update Gate the flags fallback on the absence of both --json and --file instead of on the payload being empty, so an explicitly selected empty file or empty stdin reaches JSON parsing and fails before any API request. Mirrors the providers update fix and adds empty-file/stdin tests for agents create, agents update and providers update. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
7a3ce28 to
f0ff71b
Compare

🤔 What
Adds
--file/-f(and-for stdin) next to inline--jsonon Agent Studio create/update commands that take a JSON payload.🤷 Why
#290 ships providers create/update with
--jsononly. Large payloads and API keys are awkward on argv.--fileis an additional source, not a replacement.🔍 How
agentstudio agents create/updateandagentstudio providers create/updateaccept--file/-f.cmdutil.JSONPayloadreads--jsonor--file(including-via existingReadFile).--jsonand--filecannot be combined with each other or with name/instructions flags.--jsonstill works. File contents are trimmed; parsing errors stayparsing agent JSON/parsing provider JSON.🧪 Testing
Stacked on #290. Merge #289, #288, then #290 first, or check out this branch which includes them.
Writes need
editSettings(admin keys skip the CLI ACL check). Replace<APP_ID>with an Agent Studio app. Pass--application-idif the selected profile app does not resolve. Do not commit files that contain real API keys.Quick checks
task build go test ./pkg/cmdutil ./pkg/cmd/agents/create ./pkg/cmd/agents/update ./pkg/cmd/providers/create ./pkg/cmd/providers/update -count=1 ./algolia agentstudio agents create --help ./algolia agentstudio providers create --helpExpect tests green and
--filedocumented beside--json.Scenario 1 — agents create from file
Action: write a payload file, create an agent from it, then from stdin.
Expectation: both commands return JSON with a new
idand the givenname/instructions.Scenario 2 — providers create/update from file
Action: create a provider from a file, then patch
inputfrom a file.Expectation: create returns an
idwithproviderName: "openai". Update exits 0.providerNameis unchanged.Scenario 3 — exclusive flags (failure mode)
Action: pass
--jsonand--filetogether, then--filewith--name.Expectation: each command errors.
--jsoncannot be combined with--file.--jsonand--filecannot be combined with--name(or--instructionson agents).lw-oct-agent-studio-3).Made with Cursor