Skip to content

Global OpenCode Defaults (opencode_defaults) for Model, Agent, Variant, Pure, etc. #23

Closed

Description

@maddes8cht

Description

Currently, opencode run is called without additional flags:

cmd = [self.binary, "run", prompt]

There is no way to set global defaults for --model, --agent, --pure, etc. that apply to all agents in all workflows.

A general configuration layer is needed that serves as the base for every opencode run invocation — before per-agent overrides (#22) take effect.

Design

1. New Dataclass: OpenCodeOptions

@dataclass
class OpenCodeOptions:
    model: Optional[str] = None
    agent: Optional[str] = None
    variant: Optional[str] = None
    pure: bool = False
    log_level: Optional[str] = None
    extra_args: list[str] = field(default_factory=list)

    def to_cli_args(self) -> list[str]:
        args = []
        if self.model:
            args += ["-m", self.model]
        if self.agent:
            args += ["--agent", self.agent]
        if self.variant:
            args += ["--variant", self.variant]
        if self.pure:
            args += ["--pure"]
        if self.log_level:
            args += ["--log-level", self.log_level]
        args += self.extra_args
        return args

2. Storage Locations (Override Order)

CLI > Workflow JSON > config.json > opencode built-in

(a) Global in config.json:

{
  "opencode_defaults": {
    "model": "anthropic/claude-sonnet-4",
    "agent": "plan",
    "pure": true
  }
}

(b) Workflow-specific (overrides global):

{
  "loop_agents": ["amala", "vera"],
  "opencode_defaults": {
    "model": "openai/gpt-4o"
  }
}

(c) CLI override:

python openloop.py --cli --workflow wf.json --opencode-defaults "agent=plan"

3. Config Extension

core/config.py – Config gets opencode_defaults: OpenCodeOptions.

4. WorkflowConfig Extension

core/engine.py – WorkflowConfig also gets opencode_defaults.

5. Runner Extension

OpenCodeRunner.run() accepts opts: Optional[OpenCodeOptions] = None and calls opts.to_cli_args().

6. Engine Merging

In execute_workflow_data(): Config defaults as base, merge workflow defaults (workflow wins).

7. GUI Extension

Settings dialog or config panel with fields for Model, Agent, Variant, Pure, Log-Level.

Sub-Issues (ToDo)

Distinction from #22

This issue defines the global base. Issue #22 builds on this and allows per-agent overrides. The complete merge order is:

Config (opencode_defaults) > Workflow (opencode_defaults) > Agent (agent_options) > Runner

Activity

  1. added
    enhancement
    on Jul 19, 2026
  2. added a commit that references this issue on Jul 19, 2026
  3. maddes8cht commented on Jul 20, 2026

    @maddes8cht
    OwnerAuthor

    Implemented and merged into main.

  4. changed the title [-]Globale OpenCode-Defaults (opencode_defaults) für Model, Agent, Variant, Pure etc.[/-] [+]Global OpenCode Defaults (opencode_defaults) for Model, Agent, Variant, Pure, etc.[/+] on Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions