{"record":{"id":"80aa6b96a6e6b796","repo":"micro/go-micro","slug":"agent-run-s-response-decode-w","errorCode":null,"errorMessage":"agent run %s response decode: %w","messagePattern":"agent run (.+?) response decode: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent/checkpoint.go","lineNumber":99,"sourceCode":"\t}\n\trun, ok, err := a.opts.Checkpoint.Load(ctx, runID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"agent run %s not found\", runID)\n\t}\n\tif run.Status == \"paused\" {\n\t\tif run.State.Stage == agentInputStep {\n\t\t\treturn nil, fmt.Errorf(\"agent run %s is input-required; resume with ResumeInput\", runID)\n\t\t}\n\t\trun.Status = \"running\"\n\t\trun.State.Stage = agentAskStep\n\t}\n\tif run.Status == \"done\" {\n\t\tvar resp Response\n\t\tif err := json.Unmarshal(run.State.Data, &resp); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"agent run %s response decode: %w\", runID, err)\n\t\t}\n\t\treturn &resp, nil\n\t}\n\tif terminalAgentRunStatus(run.Status) {\n\t\treturn nil, fmt.Errorf(\"agent run %s is terminal with status %q\", runID, run.Status)\n\t}\n\tmessage := string(run.State.Data)\n\tparentID := run.ParentID\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\tif a.model == nil {\n\t\ta.setup()\n\t}\n\treturn a.askLocked(ctx, run.ID, message, parentID, &run, false)\n}\n\n// ResumeInput resumes a checkpointed agent run that paused via the built-in\n// request_input tool. The supplied input is appended to the original request so","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/agent/checkpoint.go#L81-L117","documentation":"Returned when agent.Resume finds a completed (\"done\") run in the checkpoint and attempts to decode its stored response JSON into agent.Response but json.Unmarshal fails. The stored State.Data for done runs must be a valid agent.Response JSON document; corruption or incompatible schema changes break this decode.","triggerScenarios":"The checkpoint record's State.Data was written by a different library version whose Response JSON shape is incompatible, the stored bytes were truncated/corrupted, or the store returned non-JSON data for a done run.","commonSituations":"Upgrading go-micro across a Response struct change while reusing old checkpoints; checkpoint stores that mangle binary/JSON payloads; manually editing or migrating checkpoint rows.","solutions":["Delete/recreate the checkpoint entry for that run and re-run the agent from scratch, since the stored response is unrecoverable.","If upgrading library versions, drain or discard old done checkpoints, or write a migration to transform old Response JSON into the new schema.","Verify the checkpoint store round-trips JSON payloads intact (encoding, compression, size limits).","Log the underlying %w error from json.Unmarshal to pinpoint the exact schema mismatch."],"exampleFix":"// before\nresp, err := agent.Resume(ctx, ag, runID) // old-format stored response\n// after\nif err != nil && strings.Contains(err.Error(), \"response decode\") {\n    ckpt.Delete(ctx, runID)           // drop incompatible checkpoint\n    resp, err = ag.Run(ctx, originalMessage) // re-run\n}","handlingStrategy":"try-catch","validationCode":"run, ok, _ := ckpt.Load(ctx, runID)\nif ok && run.Status == \"done\" {\n    var probe agent.Response\n    if err := json.Unmarshal(run.State.Data, &probe); err != nil { /* stale/incompatible */ }\n}","typeGuard":null,"tryCatchPattern":"resp, err := agent.Resume(ctx, ag, runID)\nif err != nil && strings.Contains(err.Error(), \"response decode\") {\n    ckpt.Delete(ctx, runID)\n    resp, err = ag.Run(ctx, originalMessage)\n}","preventionTips":["Drop or migrate old checkpoints when upgrading library versions with Response schema changes.","Round-trip test your checkpoint store for JSON fidelity.","Never hand-edit checkpoint payloads."],"tags":["agent","checkpoint","json-decode","response"],"backgroundTag":"schema-validation-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}