feat(openai): per-tool MaxContextTokens prompt budget #3

Merged
thklein merged 3 commits from feat/max-context-tokens into main 2026-07-10 12:21:03 +00:00
Owner

Plumbs a new budget-only field MaxContextTokens through types/completion/engine/parser and makes the prompt-trim budget prefer it: precedence MaxContextTokens > MaxTokens (legacy) > GPTSCRIPT_DEFAULT_MAX_TOKENS env > 400k. request.MaxTokens (output limit) and isContextLengthError are untouched. Lets bpai set a per-model context window without conflating it with the output max_tokens.\n\nCommits: plumb field (+parser round-trip test); prefer it in getBudget/dropMessagesOverCount/decreaseTenPercent.

Plumbs a new budget-only field `MaxContextTokens` through types/completion/engine/parser and makes the prompt-trim budget prefer it: precedence `MaxContextTokens > MaxTokens (legacy) > GPTSCRIPT_DEFAULT_MAX_TOKENS env > 400k`. `request.MaxTokens` (output limit) and `isContextLengthError` are untouched. Lets bpai set a per-model context window without conflating it with the output max_tokens.\n\nCommits: plumb field (+parser round-trip test); prefer it in getBudget/dropMessagesOverCount/decreaseTenPercent.
TestToolMaxContextTokensRoundTrip only checked Print() output, leaving
the parser case for "Max Context Tokens" without coverage. Add a
parser-level test that parses tool text and asserts the resulting
Parameters.MaxContextTokens.
feat(openai): prefer MaxContextTokens for the prompt-trim budget
Some checks failed
Request reviewers for Dependabot PRs / request_reviewers (pull_request_target) Has been skipped
smoke / check-label (pull_request_target) Failing after 3m0s
integration / integration (ubuntu-22.04) (pull_request) Failing after 3m43s
smoke / gpt-4o-2024-08-06 (pull_request_target) Has been skipped
smoke / gpt-4o-mini-2024-07-18 (pull_request_target) Has been skipped
smoke / claude-3-7-sonnet-20250219 (pull_request_target) Has been skipped
test / test (ubuntu-22.04) (pull_request) Failing after 4m16s
Validate docs build / validate-docs (pull_request) Failing after 5m45s
test / test (windows-latest) (pull_request) Has been cancelled
integration / integration (windows-latest) (pull_request) Has been cancelled
ad411e2afd
thklein deleted branch feat/max-context-tokens 2026-07-10 12:21:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
basepeak-ai/gptscript!3
No description provided.