{"record":{"id":"8d11f346da2c488c","repo":"multica-ai/multica","slug":"update-agent-w","errorCode":null,"errorMessage":"update agent: %w","messagePattern":"update agent: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent.go","lineNumber":813,"sourceCode":"\t\t}\n\t\tbody[\"max_concurrent_tasks\"] = v\n\t}\n\tif mc, ok, err := resolveMcpConfig(cmd); err != nil {\n\t\treturn err\n\t} else if ok {\n\t\tbody[\"mcp_config\"] = mc\n\t}\n\n\tif len(body) == 0 {\n\t\treturn fmt.Errorf(\"no fields to update; use --name, --description, --instructions, --runtime-id, --runtime-config, --model, --thinking-level, --service-tier, --custom-args, --mcp-config, --visibility, --status, or --max-concurrent-tasks (env vars now live behind `multica agent env set <id>`)\")\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar result map[string]any\n\tif err := client.PutJSON(ctx, \"/api/agents/\"+args[0], body, &result); err != nil {\n\t\treturn fmt.Errorf(\"update agent: %w\", err)\n\t}\n\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, result)\n\t}\n\n\tfmt.Printf(\"Agent updated: %s (%s)\\n\", strVal(result, \"name\"), strVal(result, \"id\"))\n\treturn nil\n}\n\nfunc runAgentArchive(cmd *cobra.Command, args []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := cli.APIContext(context.Background())","sourceCodeStart":795,"sourceCodeEnd":831,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent.go#L795-L831","documentation":"Wrapped error returned when `multica agent update <id>` fails to PUT the changed-field body to `PUT /api/agents/{id}`. The %w carries the API client failure: unknown agent id (404), auth failure, connectivity loss, or server-side validation of the new field values.","triggerScenarios":"`multica agent update <id> --name X` where <id> does not exist or is archived, the server is unreachable, the token is invalid, or the server rejects the new value (e.g. invalid model string or negative max-concurrent-tasks).","commonSituations":"Using an agent id from another workspace, agent was archived between listing and updating, expired session, or passing a value the CLI accepts but the server rejects.","solutions":["Confirm the agent exists: `multica agent get <id>` (or list) — fix or re-copy the id","If archived, restore first: `multica agent restore <id>`","Check connectivity/auth (server running, MULTICA_API_URL and token valid)","Act on the wrapped cause text — it names the rejected field for 400 responses"],"exampleFix":"# before\nmultica agent update agt_stale --status active\n# Error: update agent: 404: agent not found\n\n# after\nmultica agent list                 # find the current id\nmultica agent update agt_real --status active","handlingStrategy":"try-catch","validationCode":"multica agent get \"$AGENT_ID\" >/dev/null 2>&1 || { echo 'agent id invalid or unreachable'; exit 1; }\nmultica agent update \"$AGENT_ID\" --name \"$NAME\"","typeGuard":null,"tryCatchPattern":"if err := client.PutJSON(ctx, \"/api/agents/\"+id, body, &result); err != nil {\n\treturn fmt.Errorf(\"update agent: %w\", err) // inspect 404 vs 400 vs network\n}","preventionTips":["Pre-check agent existence with `agent get` before updating in scripts","Handle 404 as 'agent gone' rather than retrying","Keep agent ids in a single source of truth refreshed by `agent list`"],"tags":["cli","api","network","agent"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}