Skip to content

[FEATURE]: AI-callable Config tool for runtime self-configuration by agents #20481

@borealBytes

Description

@borealBytes

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

There is currently no way for an agent to read or modify OpenCode settings mid-session. Agents that want to switch models, enable auto-compact, adjust verbosity, or toggle permissions must ask the user to do it manually — breaking the agentic loop and creating unnecessary interruptions.

claw-code exposes a Config tool at the AI tool layer so agents can self-configure during a session. OpenCode has settings infrastructure but no AI-callable interface to it.

Proposed solution

Add a Config tool accessible to agents with two modes: get (read current value) and set (update a value).

// packages/opencode/src/tool/config.ts

export const ConfigTool = Tool.define({
  name: "Config",
  description: "Get or set an OpenCode runtime setting.",
  parameters: z.object({
    setting: z.string(),
    value: z.union([z.string(), z.boolean(), z.number()]).optional()
  }),
  execute: async ({ setting, value }) => {
    if (value === undefined) {
      return { operation: "get", setting, value: Config.get(setting) }
    }
    const previous = Config.get(setting)
    Config.set(setting, value)
    return { operation: "set", setting, previousValue: previous, newValue: value }
  }
})

Suggested configurable settings

Setting Type Description
model string Switch active model mid-session
autoCompactEnabled boolean Toggle automatic context compaction
verbose boolean Enable/disable verbose tool output
permissions.defaultMode string "approve" | "ignore" | "auto"
theme string UI theme
alwaysThinkingEnabled boolean Force extended thinking on/off
showTurnDuration boolean Display per-turn timing

Why this matters

  • Self-adjusting orchestrators can downgrade model mid-session to save cost once planning is done
  • Background agents can turn off verbose output after bootstrapping
  • Multi-agent frameworks can toggle permissions per sub-task without user interruption

Acceptance criteria

  • Config tool is registered in the tool manifest with ReadOnly permission for get, WorkspaceWrite for set
  • Attempting to set an unknown setting returns a clear error, not a silent no-op
  • Setting model mid-session takes effect on the next LLM call in the current session
  • All settings changes are logged to the session event stream for auditability
  • Permission mode required for set operations is enforced (agent cannot escalate its own permissions)

Related / cross-reference

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions