chore: merge dev into v2 (#37170)
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Jay <53023+jayair@users.noreply.github.com> Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: Luke Parker <10430890+Hona@users.noreply.github.com> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com> Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com> Co-authored-by: Simon Klee <hello@simonklee.dk> Co-authored-by: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Co-authored-by: opencode <opencode@sst.dev> Co-authored-by: Aiden Cline <aidenpcline@gmail.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: Aarav Sareen <96787824+arvsrn@users.noreply.github.com> Co-authored-by: James Long <longster@gmail.com> Co-authored-by: James Long <jlongster@users.noreply.github.com> Co-authored-by: Dustin Deus <deusdustin@gmail.com> Co-authored-by: 冯基魁 <56265583+fengjikui@users.noreply.github.com> Co-authored-by: Frank <frank@anoma.ly> Co-authored-by: Aiden Cline <rekram1-node@users.noreply.github.com> Co-authored-by: Kit Langton <kit.langton@gmail.com> Co-authored-by: David Hill <1879069+iamdavidhill@users.noreply.github.com> Co-authored-by: usrnk1 <7547651+usrnk1@users.noreply.github.com> Co-authored-by: Victor Navarro <vn4varro@gmail.com> Co-authored-by: Dax Raad <d@ironbay.co> Co-authored-by: Dax <mail@thdxr.com> Co-authored-by: Nabs <nabil@instafork.com> Co-authored-by: Vladimir Glafirov <vglafirov@gitlab.com> Co-authored-by: AidenGeunGeun <eastlandwyvern@gmail.com> Co-authored-by: Mark <geraint0923@users.noreply.github.com> Co-authored-by: Jay <air@live.ca> Co-authored-by: BB84 <110078428+BB-84C@users.noreply.github.com>
This commit is contained in:
co-authored by
opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Jay
Brendan Allan
Luke Parker
Brendan Allan
opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Simon Klee
Aiden Cline
opencode
Aiden Cline
Adam
Aarav Sareen
James Long
James Long
Dustin Deus
冯基魁
Frank
Aiden Cline
Kit Langton
David Hill
usrnk1
Victor Navarro
Dax Raad
Dax
Nabs
Vladimir Glafirov
AidenGeunGeun
Mark
Jay
BB84
parent
720f062cd0
commit
7624c4f7b3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"version": "1.17.20",
|
||||
"version": "1.18.2",
|
||||
"name": "opencode",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1152,7 +1152,7 @@ export function options(input: {
|
||||
}
|
||||
|
||||
if (input.model.providerID === "meta" && input.model.api.npm === "@ai-sdk/openai") {
|
||||
result["reasoningEffort"] = "high"
|
||||
result["reasoningEffort"] = "xhigh"
|
||||
result["reasoningSummary"] = "auto"
|
||||
result["include"] = INCLUDE_ENCRYPTED_REASONING
|
||||
}
|
||||
|
||||
@@ -91,6 +91,21 @@ export const TaskTool = Tool.define(
|
||||
const cfg = yield* config.get()
|
||||
const runInBackground = params.background === true
|
||||
|
||||
const parent = yield* sessions.get(ctx.sessionID)
|
||||
let current = parent
|
||||
let depth = 0
|
||||
while (current.parentID) {
|
||||
depth++
|
||||
current = yield* sessions.get(current.parentID)
|
||||
}
|
||||
if (depth >= (cfg.subagent_depth ?? 1)) {
|
||||
return yield* Effect.fail(
|
||||
new Error(
|
||||
`Subagent depth limit reached (${cfg.subagent_depth ?? 1}). Increase "subagent_depth" to allow nested subagents.`,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
if (!ctx.extra?.bypassAgentCheck) {
|
||||
yield* ctx.ask({
|
||||
permission: id,
|
||||
@@ -111,7 +126,6 @@ export const TaskTool = Tool.define(
|
||||
const session = params.task_id
|
||||
? yield* sessions.get(SessionID.make(params.task_id)).pipe(Effect.catchCause(() => Effect.succeed(undefined)))
|
||||
: undefined
|
||||
const parent = yield* sessions.get(ctx.sessionID)
|
||||
const childPermission = deriveSubagentSessionPermission({
|
||||
parentSessionPermission: parent.permission ?? [],
|
||||
subagent: next,
|
||||
|
||||
@@ -387,6 +387,86 @@ describe("tool.task", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.instance("prevents subagents from launching subagents by default", () =>
|
||||
Effect.gen(function* () {
|
||||
const sessions = yield* Session.Service
|
||||
const { chat, assistant } = yield* seed()
|
||||
const child = yield* sessions.create({ parentID: chat.id, title: "child" })
|
||||
const nestedAssistant = yield* sessions.updateMessage({
|
||||
...assistant,
|
||||
id: MessageID.ascending(),
|
||||
parentID: MessageID.ascending(),
|
||||
sessionID: child.id,
|
||||
})
|
||||
const tool = yield* TaskTool
|
||||
const def = yield* tool.init()
|
||||
let asked = false
|
||||
|
||||
const exit = yield* def
|
||||
.execute(
|
||||
{
|
||||
description: "inspect bug",
|
||||
prompt: "look into the cache key path",
|
||||
subagent_type: "general",
|
||||
},
|
||||
{
|
||||
sessionID: child.id,
|
||||
messageID: nestedAssistant.id,
|
||||
agent: "general",
|
||||
abort: new AbortController().signal,
|
||||
extra: { promptOps: stubOps() },
|
||||
messages: [],
|
||||
metadata: () => Effect.void,
|
||||
ask: () => Effect.sync(() => (asked = true)),
|
||||
},
|
||||
)
|
||||
.pipe(Effect.exit)
|
||||
|
||||
expect(Exit.isFailure(exit)).toBe(true)
|
||||
expect(asked).toBe(false)
|
||||
expect(yield* sessions.children(child.id)).toHaveLength(0)
|
||||
}),
|
||||
)
|
||||
|
||||
it.instance(
|
||||
"allows nested subagents up to the configured depth",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const sessions = yield* Session.Service
|
||||
const { chat, assistant } = yield* seed()
|
||||
const child = yield* sessions.create({ parentID: chat.id, title: "child" })
|
||||
const nestedAssistant = yield* sessions.updateMessage({
|
||||
...assistant,
|
||||
id: MessageID.ascending(),
|
||||
parentID: MessageID.ascending(),
|
||||
sessionID: child.id,
|
||||
})
|
||||
const tool = yield* TaskTool
|
||||
const def = yield* tool.init()
|
||||
|
||||
const result = yield* def.execute(
|
||||
{
|
||||
description: "inspect bug",
|
||||
prompt: "look into the cache key path",
|
||||
subagent_type: "general",
|
||||
},
|
||||
{
|
||||
sessionID: child.id,
|
||||
messageID: nestedAssistant.id,
|
||||
agent: "general",
|
||||
abort: new AbortController().signal,
|
||||
extra: { promptOps: stubOps() },
|
||||
messages: [],
|
||||
metadata: () => Effect.void,
|
||||
ask: () => Effect.void,
|
||||
},
|
||||
)
|
||||
|
||||
expect((yield* sessions.get(result.metadata.sessionId)).parentID).toBe(child.id)
|
||||
}),
|
||||
{ config: { subagent_depth: 2 } },
|
||||
)
|
||||
|
||||
it.instance(
|
||||
"execute shapes child permissions for task and primary tools",
|
||||
() =>
|
||||
|
||||
Reference in New Issue
Block a user