{"record":{"id":"8b332b9f91190620","repo":"dagger/dagger","slug":"startinteractivepromptmode-no-id-found-in-llm-obj","errorCode":null,"errorMessage":"startInteractivePromptMode: no ID found in LLM object: %+v","messagePattern":"startInteractivePromptMode: no ID found in LLM object: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/dagger/functions.go","lineNumber":1096,"sourceCode":"\treturn startInteractivePromptModeWithResume(ctx, dag, response, \"\", false)\n}\n\n// startInteractivePromptModeWithResume is like startInteractivePromptMode but\n// optionally resumes a previously saved session before entering the interactive\n// loop. When resume is true and sessionID is empty, an interactive picker is\n// shown; when sessionID is non-empty, that session is resumed directly. The\n// resumed conversation replaces the composed LLM as the starting point.\nfunc startInteractivePromptModeWithResume(ctx context.Context, dag *dagger.Client, response any, sessionID string, resume bool) error {\n\t// Extract the LLM ID from the response\n\tvar llmID string\n\tswitch v := response.(type) {\n\tcase string:\n\t\tllmID = v\n\tcase map[string]any:\n\t\tif id, ok := v[\"id\"].(string); ok {\n\t\t\tllmID = id\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"startInteractivePromptMode: no ID found in LLM object: %+v\", v)\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"startInteractivePromptMode: unexpected response type for LLM: %T\", v)\n\t}\n\n\t// Set up the shell handler with prompt mode\n\thandler := newShellCallHandler(dag, Frontend)\n\thandler.mode = modePrompt\n\n\t// Initialize the handler\n\tif err := handler.Initialize(ctx); err != nil {\n\t\treturn err\n\t}\n\n\t// Load the LLM from the ID and assign it as $agent\n\tllm := dagger.Ref[*dagger.LLM](dag, dagger.ID(llmID))\n\tif _, err := handler.llm(ctx); err != nil { // init llmSession\n\t\treturn err","sourceCodeStart":1078,"sourceCodeEnd":1114,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/internal/cmd/dagger/functions.go#L1078-L1114","documentation":"startInteractivePromptMode(WithResume) extracts an LLM ID from the function response: if the response is a map[string]any it must contain a string 'id' key. This error means the map-shaped LLM response lacked an 'id' field, so the interactive prompt shell cannot load the LLM.","triggerScenarios":"A module function returning an object serialized to a map without an 'id' key (e.g. a custom struct or partial object instead of a dagger LLM), then passed to `dagger call ... --interactive` / prompt mode.","commonSituations":"Module authors returning a plain object from the function intended for prompt mode; GraphQL/JSON deserialization producing a map missing 'id' after an API change; mixing object and ID return types across module versions.","solutions":["Make the function return an actual LLM object (or its ID string) so the response carries an 'id' field.","If the response is a map, ensure it includes {\"id\": \"<valid LLM ID>\"}.","Update the module to a version whose prompt-mode entry function returns dagger.LLM."],"exampleFix":"// before (module returns plain object)\nfunc (m *Mod) Assistant() map[string]any { return map[string]any{\"model\": \"gpt\"} }\n// after\nfunc (m *Mod) Assistant() *dagger.LLM { return dag.LLM() }","handlingStrategy":"type-guard","validationCode":"m, ok := response.(map[string]any)\nif ok {\n    if _, hasID := m[\"id\"].(string); !hasID {\n        return errors.New(\"response object missing id\")\n    }\n}","typeGuard":"func hasLLMID(response any) bool {\n    switch v := response.(type) {\n    case string:\n        return v != \"\"\n    case map[string]any:\n        _, ok := v[\"id\"].(string)\n        return ok\n    default:\n        return false\n    }\n}","tryCatchPattern":"if err := startInteractivePromptMode(ctx, dag, resp); err != nil {\n    if strings.Contains(err.Error(), \"no ID found in LLM object\") {\n        // inspect resp and fix module return type\n    }\n}","preventionTips":["Return *dagger.LLM from prompt-mode entry functions","Validate the response shape in the module before returning","Pin module and CLI versions to avoid shape drift"],"tags":["cli","llm","interactive","response-shape"],"backgroundTag":"missing-id-field","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}