mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-14 20:54:42 +00:00
feat: cherries
This commit is contained in:
@@ -12,3 +12,4 @@ Focus on information that would be helpful for continuing the conversation, incl
|
|||||||
Your summary should be comprehensive enough to provide context but concise enough to be quickly understood.
|
Your summary should be comprehensive enough to provide context but concise enough to be quickly understood.
|
||||||
|
|
||||||
Do not respond to any questions in the conversation, only output the summary.
|
Do not respond to any questions in the conversation, only output the summary.
|
||||||
|
Respond in the same language the user used in the conversation.
|
||||||
|
|||||||
@@ -302,6 +302,11 @@ export const RunCommand = cmd({
|
|||||||
describe: "show thinking blocks",
|
describe: "show thinking blocks",
|
||||||
default: false,
|
default: false,
|
||||||
})
|
})
|
||||||
|
.option("dangerously-skip-permissions", {
|
||||||
|
type: "boolean",
|
||||||
|
describe: "auto-approve permissions that are not explicitly denied (dangerous!)",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
handler: async (args) => {
|
handler: async (args) => {
|
||||||
let message = [...args.message, ...(args["--"] || [])]
|
let message = [...args.message, ...(args["--"] || [])]
|
||||||
@@ -544,15 +549,23 @@ export const RunCommand = cmd({
|
|||||||
if (event.type === "permission.asked") {
|
if (event.type === "permission.asked") {
|
||||||
const permission = event.properties
|
const permission = event.properties
|
||||||
if (permission.sessionID !== sessionID) continue
|
if (permission.sessionID !== sessionID) continue
|
||||||
UI.println(
|
|
||||||
UI.Style.TEXT_WARNING_BOLD + "!",
|
if (args["dangerously-skip-permissions"]) {
|
||||||
UI.Style.TEXT_NORMAL +
|
await sdk.permission.reply({
|
||||||
`permission requested: ${permission.permission} (${permission.patterns.join(", ")}); auto-rejecting`,
|
requestID: permission.id,
|
||||||
)
|
reply: "once",
|
||||||
await sdk.permission.reply({
|
})
|
||||||
requestID: permission.id,
|
} else {
|
||||||
reply: "reject",
|
UI.println(
|
||||||
})
|
UI.Style.TEXT_WARNING_BOLD + "!",
|
||||||
|
UI.Style.TEXT_NORMAL +
|
||||||
|
`permission requested: ${permission.permission} (${permission.patterns.join(", ")}); auto-rejecting`,
|
||||||
|
)
|
||||||
|
await sdk.permission.reply({
|
||||||
|
requestID: permission.id,
|
||||||
|
reply: "reject",
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1074,6 +1074,7 @@ export namespace Provider {
|
|||||||
options: mergeDeep(existingModel?.options ?? {}, model.options ?? {}),
|
options: mergeDeep(existingModel?.options ?? {}, model.options ?? {}),
|
||||||
limit: {
|
limit: {
|
||||||
context: model.limit?.context ?? existingModel?.limit?.context ?? 0,
|
context: model.limit?.context ?? existingModel?.limit?.context ?? 0,
|
||||||
|
input: model.limit?.input ?? existingModel?.limit?.input,
|
||||||
output: model.limit?.output ?? existingModel?.limit?.output ?? 0,
|
output: model.limit?.output ?? existingModel?.limit?.output ?? 0,
|
||||||
},
|
},
|
||||||
headers: mergeDeep(existingModel?.headers ?? {}, model.headers ?? {}),
|
headers: mergeDeep(existingModel?.headers ?? {}, model.headers ?? {}),
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ export namespace SessionCompaction {
|
|||||||
const defaultPrompt = `Provide a detailed prompt for continuing our conversation above.
|
const defaultPrompt = `Provide a detailed prompt for continuing our conversation above.
|
||||||
Focus on information that would be helpful for continuing the conversation, including what we did, what we're doing, which files we're working on, and what we're going to do next.
|
Focus on information that would be helpful for continuing the conversation, including what we did, what we're doing, which files we're working on, and what we're going to do next.
|
||||||
The summary that you construct will be used so that another agent can read it and continue the work.
|
The summary that you construct will be used so that another agent can read it and continue the work.
|
||||||
|
Respond in the same language as the user's messages in the conversation.
|
||||||
|
|
||||||
When constructing the summary, try to stick to this template:
|
When constructing the summary, try to stick to this template:
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -319,9 +319,18 @@ export namespace SessionPrompt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!lastUser) throw new Error("No user message found in stream. This should never happen.")
|
if (!lastUser) throw new Error("No user message found in stream. This should never happen.")
|
||||||
|
|
||||||
|
const lastAssistantMsg = msgs.findLast(
|
||||||
|
(msg) => msg.info.role === "assistant" && msg.info.id === lastAssistant?.id,
|
||||||
|
)
|
||||||
|
// Some providers return "stop" even when the assistant message contains tool calls.
|
||||||
|
// Keep the loop running so tool results can be sent back to the model.
|
||||||
|
const hasToolCalls = lastAssistantMsg?.parts.some((part) => part.type === "tool") ?? false
|
||||||
|
|
||||||
if (
|
if (
|
||||||
lastAssistant?.finish &&
|
lastAssistant?.finish &&
|
||||||
!["tool-calls", "unknown"].includes(lastAssistant.finish) &&
|
!["tool-calls"].includes(lastAssistant.finish) &&
|
||||||
|
!hasToolCalls &&
|
||||||
lastUser.id < lastAssistant.id
|
lastUser.id < lastAssistant.id
|
||||||
) {
|
) {
|
||||||
log.info("exiting loop", { sessionID })
|
log.info("exiting loop", { sessionID })
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export namespace Tool {
|
|||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
init: async (initCtx) => {
|
init: async (initCtx) => {
|
||||||
const toolInfo = init instanceof Function ? await init(initCtx) : init
|
const toolInfo = init instanceof Function ? await init(initCtx) : { ...init }
|
||||||
const execute = toolInfo.execute
|
const execute = toolInfo.execute
|
||||||
toolInfo.execute = async (args, ctx) => {
|
toolInfo.execute = async (args, ctx) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user