-
Notifications
You must be signed in to change notification settings - Fork 19.8k
feat(core): allow disabling tool output truncation #28907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 6 commits
6d3c4c9
1edba25
7a58560
7cfcb64
3fcdf94
93cc5e8
d4f83ba
5d929f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { Effect, Stream } from "effect" | ||
| import { Effect, Option, Stream } from "effect" | ||
| import os from "os" | ||
| import { createWriteStream } from "node:fs" | ||
| import * as Tool from "./tool" | ||
|
|
@@ -433,7 +433,10 @@ export const ShellTool = Tool.define( | |
| ctx: Tool.Context, | ||
| ) { | ||
| const limits = yield* trunc.limits() | ||
| const keep = limits.maxBytes * 2 | ||
| const keep = Option.match(limits, { | ||
| onNone: () => Number.POSITIVE_INFINITY, | ||
| onSome: (l) => l.maxBytes * 2, | ||
| }) | ||
| let full = "" | ||
| let last = "" | ||
| const list: Chunk[] = [] | ||
|
|
@@ -499,7 +502,7 @@ export const ShellTool = Tool.define( | |
| sink?.write(chunk) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: when |
||
| } else { | ||
| full += chunk | ||
| if (Buffer.byteLength(full, "utf-8") > limits.maxBytes) { | ||
| if (Option.isSome(limits) && Buffer.byteLength(full, "utf-8") > limits.value.maxBytes) { | ||
| return trunc.write(full).pipe( | ||
| Effect.andThen((next) => | ||
| Effect.sync(() => { | ||
|
|
@@ -566,7 +569,10 @@ export const ShellTool = Tool.define( | |
| } | ||
| if (aborted) meta.push("User aborted the command") | ||
| const raw = list.map((item) => item.text).join("") | ||
| const end = tail(raw, limits.maxLines, limits.maxBytes) | ||
| const end = Option.match(limits, { | ||
| onNone: () => ({ text: raw, cut: false }), | ||
| onSome: (l) => tail(raw, l.maxLines, l.maxBytes), | ||
| }) | ||
| if (end.cut) cut = true | ||
| if (!file && end.cut) { | ||
| file = yield* trunc.write(raw) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.