Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/opencode/src/agent/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const Info = Schema.Struct({
prompt: Schema.optional(Schema.String),
options: Schema.Record(Schema.String, Schema.Unknown),
steps: Schema.optional(Schema.Finite),
thinking: Schema.optional(Schema.Boolean),
}).annotate({ identifier: "Agent" })
export type Info = DeepMutable<Schema.Schema.Type<typeof Info>>

Expand Down Expand Up @@ -302,6 +303,7 @@ export const layer = Layer.effect(
item.hidden = value.hidden ?? item.hidden
item.name = value.name ?? item.name
item.steps = value.steps ?? item.steps
item.thinking = value.thinking ?? item.thinking
item.options = mergeDeep(item.options, value.options ?? {})
item.permission = Permission.merge(item.permission, Permission.fromConfig(value.permission ?? {}))
}
Expand Down
7 changes: 7 additions & 0 deletions packages/opencode/src/cli/cmd/tui/context/sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({

case "permission.asked": {
const request = event.properties
if (kv.get("yolo_mode", false)) {
void sdk.client.permission.reply({
requestID: request.id,
reply: "once",
})
break
}
const requests = store.permission[request.sessionID]
if (!requests) {
setStore("permission", request.sessionID, [request])
Expand Down
5 changes: 5 additions & 0 deletions packages/opencode/src/cli/cmd/tui/routes/session/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { useDirectory } from "../../context/directory"
import { useConnected } from "../../component/use-connected"
import { createStore } from "solid-js/store"
import { useRoute } from "../../context/route"
import { useKV } from "../../context/kv"

export function Footer() {
const { theme } = useTheme()
const sync = useSync()
const route = useRoute()
const kv = useKV()
const mcp = createMemo(() => Object.values(sync.data.mcp).filter((x) => x.status === "connected").length)
const mcpError = createMemo(() => Object.values(sync.data.mcp).some((x) => x.status === "failed"))
const lsp = createMemo(() => Object.keys(sync.data.lsp))
Expand Down Expand Up @@ -82,6 +84,9 @@ export function Footer() {
{mcp()} MCP
</text>
</Show>
<Show when={kv.get("yolo_mode", false)}>
<text fg={theme.warning}>YOLO</text>
</Show>
<text fg={theme.textMuted}>/status</text>
</Match>
</Switch>
Expand Down
19 changes: 19 additions & 0 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const sessionBindingCommands = [
"session.toggle.actions",
"session.toggle.scrollbar",
"session.toggle.generic_tool_output",
"session.toggle.yolo",
"session.page.up",
"session.page.down",
"session.line.up",
Expand Down Expand Up @@ -226,6 +227,7 @@ export function Session() {
const [diffWrapMode] = kv.signal<"word" | "none">("diff_wrap_mode", "word")
const [_animationsEnabled, _setAnimationsEnabled] = kv.signal("animations_enabled", true)
const [showGenericToolOutput, setShowGenericToolOutput] = kv.signal("generic_tool_output_visibility", false)
const [yoloMode, setYoloMode] = kv.signal("yolo_mode", false)

const wide = createMemo(() => dimensions().width > 120)
const sidebarVisible = createMemo(() => {
Expand Down Expand Up @@ -730,6 +732,23 @@ export function Session() {
dialog.clear()
},
},
{
title: yoloMode() ? "Disable YOLO mode" : "Enable YOLO mode",
value: "session.toggle.yolo",
category: "Session",
slash: {
name: "yolo",
},
run: () => {
const next = !yoloMode()
setYoloMode(next)
toast.show({
message: next ? "YOLO mode enabled — permissions will be auto-approved" : "YOLO mode disabled",
variant: next ? "warning" : "success",
})
dialog.clear()
},
},
{
title: "Page up",
value: "session.page.up",
Expand Down
9 changes: 8 additions & 1 deletion packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useTheme } from "../../context/theme"
import { useTuiConfig } from "../../context/tui-config"
import { InstallationChannel, InstallationVersion } from "@opencode-ai/core/installation/version"
import { TuiPluginRuntime } from "@/cli/cmd/tui/plugin/runtime"
import { useKV } from "../../context/kv"

import { getScrollAcceleration } from "../../util/scroll"
import { WorkspaceLabel } from "../../component/workspace-label"
Expand All @@ -14,6 +15,7 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
const sync = useSync()
const { theme } = useTheme()
const tuiConfig = useTuiConfig()
const kv = useKV()
const session = createMemo(() => sync.session.get(props.sessionID))
const workspace = () => {
const workspaceID = session()?.workspaceID
Expand Down Expand Up @@ -85,7 +87,12 @@ export function Sidebar(props: { sessionID: string; overlay?: boolean }) {
</box>
</scrollbox>

<box flexShrink={0} gap={1} paddingTop={1}>
<box flexShrink={0} gap={1} paddingTop={1} flexDirection="column">
<Show when={kv.get("yolo_mode", false)}>
<text fg={theme.warning}>
<b>YOLO MODE</b>
</text>
</Show>
<TuiPluginRuntime.Slot name="sidebar_footer" mode="single_winner" session_id={props.sessionID}>
<text fg={theme.textMuted}>
<span style={{ fg: theme.success }}>•</span> <b>Open</b>
Expand Down
4 changes: 4 additions & 0 deletions packages/opencode/src/config/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const AgentSchema = Schema.StructWithRest(
description: "Maximum number of agentic iterations before forcing text-only response",
}),
maxSteps: Schema.optional(PositiveInt).annotate({ description: "@deprecated Use 'steps' field instead." }),
thinking: Schema.optional(Schema.Boolean).annotate({
description: "Override thinking/reasoning mode for this agent (true=force on, false=force off, undefined=use model default)",
}),
permission: Schema.optional(ConfigPermission.Info),
}),
[Schema.Record(Schema.String, Schema.Any)],
Expand All @@ -63,6 +66,7 @@ const KNOWN_KEYS = new Set([
"color",
"steps",
"maxSteps",
"thinking",
"options",
"permission",
"disable",
Expand Down
18 changes: 18 additions & 0 deletions packages/opencode/src/session/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,24 @@ const live: Layer.Layer<
providerOptions: item.options,
})
const options = mergeOptions(mergeOptions(mergeOptions(base, input.model.options), input.agent.options), variant)

// Apply agent-level thinking override
if (input.agent.thinking === false) {
// Strip all thinking/reasoning related options to disable thinking
delete options.thinking
delete options.thinkingConfig
delete options.reasoning
delete options.reasoningEffort
delete options.reasoningConfig
delete options.enable_thinking
delete options.chat_template_args
} else if (input.agent.thinking === true && !input.small) {
// Force-enable thinking by ensuring the model's default thinking options are present
// The base options from ProviderTransform.options() already include thinking defaults
// for reasoning-capable models, so we just need to make sure they weren't stripped
// by agent.options or variant. If the model doesn't support reasoning, this is a no-op.
}

if (isOpenaiOauth) {
options.instructions = system.join("\n")
}
Expand Down
Loading