Skip to content

Fix MaxOutputTokens to prevent runaway generation dominating bill and… - #4

Merged
JesseLiberty merged 1 commit into
mainfrom
doctorFixes
Jul 29, 2026
Merged

Fix MaxOutputTokens to prevent runaway generation dominating bill and…#4
JesseLiberty merged 1 commit into
mainfrom
doctorFixes

Conversation

@JesseLiberty

Copy link
Copy Markdown
Owner

… latency

Copilot AI review requested due to automatic review settings July 29, 2026 15:59
@JesseLiberty
JesseLiberty merged commit 47077b0 into main Jul 29, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR applies a per-invocation MaxOutputTokens cap when running ChatClientAgent calls to prevent a single agent turn from generating excessive output that dominates cost and increases latency.

Changes:

  • Store chatOptions.MaxOutputTokens per agent instance.
  • Pass ChatClientAgentRunOptions with MaxOutputTokens on each RunAsync/RunAsync<T> invocation.
  • Apply the cap consistently across Author/Researcher/Reviewer/Blogger agents.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
ReviewerAgent.cs Applies per-run MaxOutputTokens cap for review turns.
ResearcherAgent.cs Applies per-run MaxOutputTokens cap for research runs (including tool-calling).
BloggerAgent.cs Applies per-run MaxOutputTokens cap for structured decision generation.
AuthorAgent.cs Applies per-run MaxOutputTokens cap for drafting/revision turns.

Comment thread ReviewerAgent.cs
Comment on lines +74 to 76
AgentResponse response = await _agent.RunAsync(message, options: runOptions);
string content = response.Text;
return !string.IsNullOrEmpty(content) ? content : "APPROVED";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants