multica-ai/multica · error

workspace_id is required: MULTICA_WORKSPACE_ID must be set b

Error message

workspace_id is required: MULTICA_WORKSPACE_ID must be set by the daemon in agent execution context (no fallback to user config)

What it means

requireWorkspaceID found no workspace ID while in daemon-managed execution context. There is deliberately no fallback to user config in agent context: the daemon must inject MULTICA_WORKSPACE_ID, and its absence means the task runtime mis-injected the environment — the error says so instead of silently using the human's default workspace.

Source

Thrown at server/cmd/multica/cmd_agent.go:503

	}
	// Inside an agent task the daemon is the only authority on workspace
	// identity. Never read the user-global CLI config here.
	if inDaemonManagedExecutionContext() {
		return ""
	}
	profile := resolveProfile(cmd)
	cfg, _ := cli.LoadCLIConfigForProfile(profile)
	return cfg.WorkspaceID
}

// requireWorkspaceID resolves the workspace ID and returns an error with
// actionable instructions if it is empty (e.g. user has multiple workspaces
// but no default configured).
func requireWorkspaceID(cmd *cobra.Command) (string, error) {
	id := resolveWorkspaceID(cmd)
	if id == "" {
		if inDaemonManagedExecutionContext() {
			return "", fmt.Errorf("workspace_id is required: MULTICA_WORKSPACE_ID must be set by the daemon in agent execution context (no fallback to user config)")
		}
		return "", fmt.Errorf("workspace_id is required: use --workspace-id flag, set MULTICA_WORKSPACE_ID env, or run 'multica config set workspace_id <id>'")
	}
	return id, nil
}

// ---------------------------------------------------------------------------
// Agent commands
// ---------------------------------------------------------------------------

func runAgentList(cmd *cobra.Command, _ []string) error {
	client, err := newAPIClient(cmd)
	if err != nil {
		return err
	}
	if client.WorkspaceID == "" {
		if _, err := requireWorkspaceID(cmd); err != nil {
			return err

View on GitHub (pinned to 2c0912b6ec)

Solutions

  1. If human shell: unset the daemon context variables so the normal flag/config fallback applies.
  2. If real task: fix the runtime to export MULTICA_WORKSPACE_ID alongside the mat_ token and agent/task IDs.
  3. As a stopgap, pass --workspace-id explicitly on the command.

Example fix

# before: task wrapper forgets the workspace
export MULTICA_TOKEN=mat_...
multica issue list  # -> workspace_id is required ...

# after: inject it like the daemon does
export MULTICA_TOKEN=mat_...
export MULTICA_WORKSPACE_ID=ws_123
multica issue list
Defensive patterns

Strategy: validation

Validate before calling

// Custom runtimes: assert the daemon-style injection set is complete.
required := map[string]string{
    "MULTICA_TOKEN":         os.Getenv("MULTICA_TOKEN"),
    "MULTICA_WORKSPACE_ID":  os.Getenv("MULTICA_WORKSPACE_ID"),
}
for k, v := range required {
    if v == "" {
        return fmt.Errorf("missing required task env %s", k)
    }
}

Prevention

When it happens

Trigger: inDaemonManagedExecutionContext() is true and MULTICA_WORKSPACE_ID is empty while neither --workspace-id nor config provides an ID (config fallback is intentionally suppressed here).

Common situations: Custom task wrappers or Docker-based runtimes that whitelist env vars and drop MULTICA_WORKSPACE_ID; a daemon bug that only injects it for certain task types; leaking daemon context vars into a human shell.

Related errors


AI-assisted analysis of multica-ai/multica@2c0912b6ec (2026-08-15). Data as JSON: /api/errors/4e0cedeb5808a733. Report an issue: GitHub.