tweak: bash metadata context truncation and truncation prompts
This commit is contained in:
parent
c39cebe971
commit
68219475c0
2 changed files with 5 additions and 4 deletions
|
|
@ -17,6 +17,7 @@ import { Shell } from "@/shell/shell"
|
|||
import { BashArity } from "@/permission/arity"
|
||||
import { Truncate } from "./truncation"
|
||||
|
||||
const MAX_METADATA_LENGTH = 30_000
|
||||
const DEFAULT_TIMEOUT = Flag.OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS || 2 * 60 * 1000
|
||||
|
||||
export const log = Log.create({ service: "bash-tool" })
|
||||
|
|
@ -177,7 +178,7 @@ export const BashTool = Tool.define("bash", async () => {
|
|||
output += chunk.toString()
|
||||
ctx.metadata({
|
||||
metadata: {
|
||||
output,
|
||||
output: output.length > MAX_METADATA_LENGTH ? output.slice(0, MAX_METADATA_LENGTH) + "\n\n..." : output,
|
||||
description: params.description,
|
||||
},
|
||||
})
|
||||
|
|
@ -245,7 +246,7 @@ export const BashTool = Tool.define("bash", async () => {
|
|||
return {
|
||||
title: params.description,
|
||||
metadata: {
|
||||
output,
|
||||
output: output.length > MAX_METADATA_LENGTH ? output.slice(0, MAX_METADATA_LENGTH) + "\n\n..." : output,
|
||||
exit: proc.exitCode,
|
||||
description: params.description,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ export namespace Truncate {
|
|||
await Bun.write(Bun.file(filepath), text)
|
||||
|
||||
const hint = hasTaskTool(agent)
|
||||
? `The tool output was too large, the full output was written to the following file: ${filepath}\nIMPORTANT: Use the Task tool to have a subagent process this file with Grep and Read (with offset/limit). Do NOT read the full file yourself - delegate to save context.`
|
||||
: `The tool output was too large, the full output was written to the following file: ${filepath}\nUse Grep to search the full content or Read with offset/limit to read specific sections.`
|
||||
? `The tool call succeeded but the output was truncated. Full output saved to: ${filepath}\nUse the Task tool to have a subagent process this file with Grep and Read (with offset/limit). Do NOT read the full file yourself - delegate to save context.`
|
||||
: `The tool call succeeded but the output was truncated. Full output saved to: ${filepath}\nUse Grep to search the full content or Read with offset/limit to view specific sections.`
|
||||
const message =
|
||||
direction === "head"
|
||||
? `${preview}\n\n...${removed} ${unit} truncated...\n\n${hint}`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue