Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ts/packages/agentSdk/src/helpers/actionHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,19 @@ export function actionResultToString(actionResult: ActionResult): string {
return fields.join("\n");
}
}

// Default cap on characters of a tool/action response body echoed back to the
// dispatcher. Conservative v1 default; not yet model-aware — a model-derived
// budget belongs in the host where the selected model is known. Callers should
// reference this instead of inlining a magic number.
export const DEFAULT_MAX_RESPONSE_CHARS = 4000;

// Truncate `text` to at most `maxChars`, appending a marker when clipped.
export function truncateText(
text: string,
maxChars: number = DEFAULT_MAX_RESPONSE_CHARS,
): string {
return text.length > maxChars
? text.slice(0, maxChars) + "\n…(truncated)"
: text;
}
3 changes: 3 additions & 0 deletions ts/packages/agents/onboarding/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
"clean": "rimraf --glob dist *.tsbuildinfo *.done.build.log",
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
"test": "npm run test:local",
"test:local": "tsx --test test/*.spec.ts",
"tsc": "tsc -b"
},
"dependencies": {
Expand All @@ -64,6 +66,7 @@
"copyfiles": "^2.4.1",
"prettier": "^3.5.3",
"rimraf": "^6.0.1",
"tsx": "^4.21.0",
"typescript": "~5.4.5",
"ws": "^8.21.1"
},
Expand Down
Loading
Loading