feat(runtime): configurable per-tool-result truncation cap
Adds LoopConfig.MaxToolResultLen with the same config > env > default precedence as the existing MaxToolConcurrency / MaxAgentDepth knobs: 1. Runtime.AgentLoop.MaxToolResultLen (>0) — config wins 2. HARNESS_MAX_TOOL_RESULT_LEN env (>0) — env fallback 3. defaultMaxToolResultLen (4000) — unchanged for back-compat The previous 4000-char cap was conservative for agents doing real engineering work (read_file, web_fetch, browser, bash output). Setting MaxToolResultLen to 16000-25000 lets a typical source file or test run land in-context without hitting spillover; spill remains the safety net for genuinely large outputs. No behaviour change for callers that don't set the field.
This commit is contained in:
1 parent
65021e1fe2
commit
e5c9b5dbb5
5 files changed
+95
-5
No files matched your search
+6
-1
@@ -13,7 +13,12 @@ import (
|
||||
"github.com/sausheong/harness/session"
|
||||
)
|
||||
|
||||
const maxToolResultLen = 4000 // truncate tool results longer than this
|
||||
// defaultMaxToolResultLen is the fallback cap used when LoopConfig.MaxToolResultLen
|
||||
// is unset and the HARNESS_MAX_TOOL_RESULT_LEN env var is unset/invalid. Tool
|
||||
// results longer than this get truncated (or spilled to disk + truncated-with-
|
||||
// marker when spillConfig is supplied). 4000 chars (~1000 tokens) is conservative
|
||||
// so behaviour is unchanged for callers that don't opt into a larger budget.
|
||||
const defaultMaxToolResultLen = 4000
|
||||
|
||||
// detectImageMIME returns the actual MIME type based on magic bytes.
|
||||
// Falls back to the provided hint if the format is unrecognized.
|
||||
|
||||
Reference in new issue
Block a user