{"record":{"id":"287dc9662db7524a","repo":"dagger/dagger","slug":"attach-llm-workspace-unexpected-result-t","errorCode":null,"errorMessage":"attach llm workspace: unexpected result %T","messagePattern":"attach llm workspace: unexpected result %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/llm.go","lineNumber":1294,"sourceCode":"// just because the dependency is held imperatively rather than structurally.\nfunc (llm *LLM) AttachDependencyResults(\n\tctx context.Context,\n\t_ dagql.AnyResult,\n\tattach func(dagql.AnyResult) (dagql.AnyResult, error),\n) ([]dagql.AnyResult, error) {\n\t_ = ctx\n\tif llm == nil || llm.mcp == nil {\n\t\treturn nil, nil\n\t}\n\tvar deps []dagql.AnyResult\n\tif llm.mcp.workspace.Self() != nil {\n\t\tattached, err := attach(llm.mcp.workspace)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"attach llm workspace: %w\", err)\n\t\t}\n\t\tws, ok := attached.(dagql.ObjectResult[*Workspace])\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"attach llm workspace: unexpected result %T\", attached)\n\t\t}\n\t\tllm.mcp.workspace = ws\n\t\tdeps = append(deps, attached)\n\t}\n\tfor i, bound := range llm.mcp.boundTools {\n\t\tif bound.object == nil {\n\t\t\t// A lazy binding (restored from a persisted session) has no loaded\n\t\t\t// object to attach; it is loaded on first dispatch instead.\n\t\t\tcontinue\n\t\t}\n\t\tattached, err := attach(bound.object)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"attach llm bound tool object: %w\", err)\n\t\t}\n\t\tobj, ok := attached.(dagql.AnyObjectResult)\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"attach llm bound tool object: unexpected result %T\", attached)\n\t\t}","sourceCodeStart":1276,"sourceCodeEnd":1312,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/llm.go#L1276-L1312","documentation":"Returned when attaching the LLM MCP workspace: the attach call succeeded but the result does not type-assert to dagql.ObjectResult[*Workspace], so the returned object is of an unexpected type. This is an internal invariant violation indicating the wrong object came back from attach.","triggerScenarios":"attach(llm.mcp.workspace) returns a non-Workspace object result, e.g. after an internal API/type change in dagql or a misconfigured attach target.","commonSituations":"Mixed CLI/engine versions where Workspace types differ; custom dagql extensions returning a different object type; corrupted internal state in the LLM MCP setup.","solutions":["Ensure the Dagger CLI and engine versions match exactly","Check whether custom modules/extensions replaced the workspace attach target","Clear cache/state and re-run to rule out stale serialized objects","Report a bug with the %T type shown in the message — this indicates an internal invariant break"],"exampleFix":"// before: mixed versions\n// dagger CLI vX against engine vY\n// after\n// upgrade both: dagger engine upgrade && dagger version (match versions)","handlingStrategy":"type-guard","validationCode":"attached, err := attach(llm.mcp.workspace)\nif err != nil { return err }\nif _, ok := attached.(dagql.ObjectResult[*Workspace]); !ok {\n\treturn fmt.Errorf(\"expected Workspace, got %T\", attached)\n}","typeGuard":"func isWorkspaceResult(r dagql.AnyResult) bool {\n\t_, ok := r.(dagql.ObjectResult[*Workspace])\n\treturn ok\n}","tryCatchPattern":"ws, err := attachWorkspace(ctx, llm)\nif err != nil && strings.Contains(err.Error(), \"unexpected result\") {\n\t// version mismatch or internal bug; align versions and re-run\n}","preventionTips":["Match CLI and engine versions exactly","Clear stale cache after upgrades","Report occurrences — this signals an internal invariant violation"],"tags":["llm","mcp","workspace","type-mismatch","internal"],"backgroundTag":"unexpected-result-type","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"}