Skip to content

model/openai: clarify token tailoring opt-in requirements - #2720

Merged
liuzengh merged 1 commit into
trpc-group:mainfrom
bytethm:docs/openai-token-tailoring-opt-in
Nov 4, 2026
Merged

liuzengh merged 1 commit into
trpc-group:mainfrom
bytethm:docs/openai-token-tailoring-opt-in

Conversation

@bytethm

@bytethm bytethm commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Clarify in OpenAI option Godoc and the English/Chinese model guides that automatic token tailoring is disabled by default and requires WithEnableTokenTailoring(true). Setting WithMaxInputTokens or WithContextWindow alone does not enable trimming before provider requests.

Why

Configuring an input limit or context window can be mistaken for enabling automatic trimming. The documentation also distinguishes that opt-in behavior from exposing the budget and window to other framework consumers, including summary processing.

Testing

  • git diff --check passed.
  • gofmt -l model/openai/options.go reported no formatting changes.
  • go test ./...: all packages passed except tool/duckduckgo, whose Unix socket test failed because the macOS default temporary path exceeded the socket path limit. The affected model/openai package passed.
  • Re-ran the entire tool/duckduckgo package with a shorter temporary directory; it passed.

Notes for reviewers

Documentation only; runtime behavior, API signatures, and defaults are unchanged.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Summary

English

The OpenAI option Godoc and the English and Chinese model guides clarify that automatic token tailoring is disabled by default. Users must set WithEnableTokenTailoring(true) to enable request-time trimming. WithMaxInputTokens and WithContextWindow configure the input budget and context window; they do not enable trimming. The docs also distinguish tailoring from making these values available to framework consumers, including summary processing.

No exported API, signature, or default changes. The update documents existing behavior and does not change runtime behavior. No operational risk is reported.

Validation: git diff --check passed, and gofmt -l model/openai/options.go reported no formatting changes. go test ./... was still running; its result is unavailable. After it completes, confirm the test result and review the documentation changes against the existing option behavior.

中文

中文

OpenAI 选项 Godoc 以及英文和中文模型指南现已说明:默认不启用自动 Token Tailoring。用户必须设置 WithEnableTokenTailoring(true),才能启用请求发送前的裁剪。WithMaxInputTokens 和 WithContextWindow 用于配置输入预算和上下文窗口,但不会启用裁剪。文档还区分了 Tailoring 与向框架消费者(包括摘要处理)提供这些值的行为。

本次更新未更改导出 API、函数签名或默认值。它只记录现有行为,不改变运行时行为。没有报告运行风险。

验证: git diff --check 已通过,gofmt -l model/openai/options.go 未报告格式变更。go test ./... 当时仍在运行,结果尚不可用。测试完成后,请确认测试结果,并核对文档与现有选项行为一致。

The OpenAI option comments and English and Chinese model guides now state that token trimming is disabled by default. They distinguish budget and context-window configuration from enabling trimming, and clarify that session summaries and context compaction require separate configuration.

Changes: Token Tailoring Documentation

Layer / File(s) Summary
Document token-tailoring options
model/openai/options.go, docs/mkdocs/en/model.md, docs/mkdocs/zh/model.md
The option comments and model guides state that trimming requires openai.WithEnableTokenTailoring(true). They explain that budget and context-window settings alone do not enable trimming, and that the configured values remain available while trimming is disabled.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Possibly related PRs

  • trpc-group/trpc-agent-go#2687: Changes token-tailoring behavior and tests native replay preservation; this PR documents the related token-tailoring contract.

Suggested reviewers: nomand-zc, rememorio

Merge Risk: Minimal · up to 73030

The documentation clarifies how to enable token trimming without changing runtime behavior or defaults. No merge-blocking issue was identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main documentation change: clarifying that token tailoring requires explicit opt-in.
Description check Passed The description directly explains the documentation updates, the opt-in requirement, the rationale, and the testing results. It is related to the changeset.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 278800a and 7303036.

Files selected for processing: 3
  • docs/mkdocs/en/model.md
  • docs/mkdocs/zh/model.md
  • model/openai/options.go

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.26298%. Comparing base (dec390b) to head (7303036).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main       #2720         +/-   ##
===================================================
- Coverage   90.26596%   90.26298%   -0.00299%     
===================================================
  Files           1291        1291                 
  Lines         234394      234394                 
===================================================
- Hits          211578      211571          -7     
- Misses         14232       14240          +8     
+ Partials        8584        8583          -1     
Flag Coverage Δ
unittests 90.26298% <ø> (-0.00299%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liuzengh liuzengh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@liuzengh
liuzengh merged commit 6877128 into trpc-group:main Nov 4, 2026
172 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants