dagger/dagger · error

attach llm workspace: unexpected result %T

Error message

attach llm workspace: unexpected result %T

What it means

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.

Source

Thrown at core/llm.go:1294

// just because the dependency is held imperatively rather than structurally.
func (llm *LLM) AttachDependencyResults(
	ctx context.Context,
	_ dagql.AnyResult,
	attach func(dagql.AnyResult) (dagql.AnyResult, error),
) ([]dagql.AnyResult, error) {
	_ = ctx
	if llm == nil || llm.mcp == nil {
		return nil, nil
	}
	var deps []dagql.AnyResult
	if llm.mcp.workspace.Self() != nil {
		attached, err := attach(llm.mcp.workspace)
		if err != nil {
			return nil, fmt.Errorf("attach llm workspace: %w", err)
		}
		ws, ok := attached.(dagql.ObjectResult[*Workspace])
		if !ok {
			return nil, fmt.Errorf("attach llm workspace: unexpected result %T", attached)
		}
		llm.mcp.workspace = ws
		deps = append(deps, attached)
	}
	for i, bound := range llm.mcp.boundTools {
		if bound.object == nil {
			// A lazy binding (restored from a persisted session) has no loaded
			// object to attach; it is loaded on first dispatch instead.
			continue
		}
		attached, err := attach(bound.object)
		if err != nil {
			return nil, fmt.Errorf("attach llm bound tool object: %w", err)
		}
		obj, ok := attached.(dagql.AnyObjectResult)
		if !ok {
			return nil, fmt.Errorf("attach llm bound tool object: unexpected result %T", attached)
		}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Ensure the Dagger CLI and engine versions match exactly
  2. Check whether custom modules/extensions replaced the workspace attach target
  3. Clear cache/state and re-run to rule out stale serialized objects
  4. Report a bug with the %T type shown in the message — this indicates an internal invariant break

Example fix

// before: mixed versions
// dagger CLI vX against engine vY
// after
// upgrade both: dagger engine upgrade && dagger version (match versions)
Defensive patterns

Strategy: type-guard

Validate before calling

attached, err := attach(llm.mcp.workspace)
if err != nil { return err }
if _, ok := attached.(dagql.ObjectResult[*Workspace]); !ok {
	return fmt.Errorf("expected Workspace, got %T", attached)
}

Type guard

func isWorkspaceResult(r dagql.AnyResult) bool {
	_, ok := r.(dagql.ObjectResult[*Workspace])
	return ok
}

Try / catch

ws, err := attachWorkspace(ctx, llm)
if err != nil && strings.Contains(err.Error(), "unexpected result") {
	// version mismatch or internal bug; align versions and re-run
}

Prevention

When it happens

Trigger: 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.

Common situations: Mixed CLI/engine versions where Workspace types differ; custom dagql extensions returning a different object type; corrupted internal state in the LLM MCP setup.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/287dc9662db7524a. Report an issue: GitHub.