Skip to content

Merge test into main#228

Merged
sweetmantech merged 1 commit intomainfrom
test
Feb 18, 2026
Merged

Merge test into main#228
sweetmantech merged 1 commit intomainfrom
test

Conversation

@sweetmantech
Copy link
Contributor

@sweetmantech sweetmantech commented Feb 18, 2026

Summary

  • Merges all changes from test branch into main

🤖 Generated with Claude Code


Note

Medium Risk
Changes the core chat execution path and configuration shape, so regressions could affect generation behavior and downstream callers expecting the old ChatConfig fields.

Overview
Shifts chat generation to run through the ToolLoopAgent instance instead of calling generateText with a large config object, updating handleChatGenerate (and eval helper) to call agent.generate(...).

Moves providerOptions (thinking/reasoning) and prepareStep tool-chain behavior into getGeneralAgent’s ToolLoopAgent construction, and simplifies setupChatRequest/ChatConfig to return only { agent, messages } (dropping system, tools, providerOptions, experimental_*, etc.). Tests are updated accordingly, including new assertions that agent settings include the baked-in providerOptions and prepareStep.

Written by Cursor Bugbot for commit c137c78. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Refactor
    • Reorganized agent configuration and provider options handling to be initialized at the agent setup level.
    • Simplified the chat request workflow by streamlining configuration management.
    • Updated the chat generation flow to use the agent's generation capabilities more directly.

* fix: use agent.generate() in /api/chat/generate and move providerOptions/prepareStep to agent constructor

The non-streaming /api/chat/generate endpoint was bypassing the ToolLoopAgent
by calling generateText() directly, while providerOptions and prepareStep were
silently ignored when passed at call time to agent.stream()/agent.generate().

Move providerOptions (thinking/reasoning budgets) and prepareStep (tool chain
orchestration) into the ToolLoopAgent constructor in getGeneralAgent.ts so they
apply consistently across all paths: streaming, non-streaming, and email.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: update setupChatRequest JSDoc to reflect current behavior

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor: trim ChatConfig to only used fields (YAGNI)

ChatConfig no longer extends RoutingDecision — now just { agent, messages }.
Removes dead fields (system, model, instructions, tools, experimental_*)
that were silently ignored by agent.generate()/agent.stream(). Fixes
evals to use agent.generate() instead of bypassing the agent via
generateText().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Contributor

vercel bot commented Feb 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-api Building Building Preview Feb 18, 2026 1:08am

Request Review

@sweetmantech sweetmantech merged commit 61d3804 into main Feb 18, 2026
2 of 4 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR refactors the chat request handling by relocating provider configuration and the prepareStep hook from setupChatRequest into getGeneralAgent, simplifying the ChatConfig type to contain only agent and messages, and updating the generation call pattern from generateText(chatConfig) to agent.generate(chatConfig).

Changes

Cohort / File(s) Summary
Type Definitions
lib/chat/types.ts
Removed provider option properties and experimental features from ChatConfig; added agent property to RoutingDecision; consolidated to a single consolidated import line; ChatConfig now contains only agent and messages.
Agent Initialization
lib/agents/generalAgent/getGeneralAgent.ts
Added provider option type imports; introduced explicit providerOptions configurations for Anthropic, Google, and OpenAI with thinking budgets and type assertions; added prepareStep hook that merges getPrepareStepResult into agent options.
Chat Flow
lib/chat/setupChatRequest.ts, lib/chat/handleChatGenerate.ts
setupChatRequest now returns minimal ChatConfig with only agent and messages properties; removed hardcoded provider options and UUID generation; handleChatGenerate replaces generateText(chatConfig) call with agent.generate(chatConfig) after destructuring agent from chatConfig.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • fix: use agent.generate() in /api/chat/generate #227: Parallel refactoring that consolidates provider options and prepareStep into ToolLoopAgent initialization, simplifies ChatConfig, and updates the generation call pattern to use agent.generate() instead of generateText().

Poem

🧩 Configuration flows to where agents dwell,
ChatConfig grows lean and clean,
Type safety holds the pattern well—
Responsibility reshuffled with care,
Architecture breathes clearer air. ✨

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on March 17

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

const { agent } = chatConfig;

const result = await generateText(chatConfig);
const result = await agent.generate(chatConfig);
Copy link

Choose a reason for hiding this comment

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

Agent passed to its own generate method unnecessarily

Low Severity

agent.generate(chatConfig) passes the entire chatConfig object, which includes the agent itself as a property ({ agent, messages }). This creates a self-referential call where the agent receives a reference to itself in its own options. The sibling call site in callChatFunctionsWithResult.ts correctly destructures and passes only { messages }. The inconsistency between these two patterns makes the code harder to reason about.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

1 participant