Skip to content

Conversation

@moqimoqidea
Copy link
Contributor

@moqimoqidea moqimoqidea commented Mar 7, 2025

Context

Fixed the issue that [Prompt Word Enhancement] cladue non-streaming call failed

Implementation

  • Due to the current Anthropic's SDK non-streaming Timeout settings, the maximum allowable token for non-streaming calls is 21333.
  • If the user configures the Claude model Max Token is greater than this number, the prompt word enhancement and other functions will immediately report an error, the specific error is as follows:
'Error: Streaming is strongly recommended for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#streaming-responses for more details\n    at Anthropic._calculateNonstreamingTimeout (/Users/moqi/Code/Roo-Code/node_modules/@anthropic-ai/sdk/src/core.ts:415:13)\n    at Messages3.create (/Users/moqi/Code/Roo-Code/node_modules/@anthropic-ai/sdk/src/resources/messages/messages.ts:64:46)\n    at AnthropicHandler.completePrompt (/Users/moqi/Code/Roo-Code/src/api/providers/anthropic.ts:224:46)\n    at WecoderHandler.completePrompt (/Users/moqi/Code/Roo-Code/src/api/providers/wecoder.ts:142:18)\n    at singleCompletionHandler (/Users/moqi/Code/Roo-Code/src/utils/single-completion-handler.ts:23:46)\n    at Lh.value (/Users/moqi/Code/Roo-Code/src/core/webview/ClineProvider.ts:1266:38)'
  • The typical user optimization prompt is generally no longer than this constant size: ANTHROPIC_DEFAULT_MAX_TOKENS
  • In the case of claude non-streaming calls, setting thinking can cause the user to wait for a very long time, In my prompt word enhancement test, using claude 3.7 and keeping think would give the following error:
"TypeError: Cannot read properties of undefined (reading 'find')\n    at AnthropicHandler.completePrompt (/Users/moqi/Code/Roo-Code/src/api/providers/anthropic.ts:236:35)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at Lh.value (/Users/moqi/Code/Roo-Code/src/core/webview/ClineProvider.ts:1266:32)"

Screenshots

before:

image

after:

No errors, successful execution of prompt word enhancements using Claude 3.7 Think

How to Test

Use the Claude 3.7 Think model to perform prompt word enhancements

Get in Touch

moqi


Important

Fixes non-streaming call issue for Claude 3.7 in completePrompt() by adjusting token handling and removing thinking parameter.

  • Behavior:
    • Fixes non-streaming call failure for Claude 3.7 in completePrompt() in anthropic.ts by setting max_tokens to ANTHROPIC_DEFAULT_MAX_TOKENS and removing thinking parameter.
    • Addresses error when maxTokens exceeds 21333 due to Anthropic's SDK timeout settings.
  • Misc:
    • Removes unused maxTokens and thinking from getModel() call in completePrompt().

This description was created by Ellipsis for aa70d75. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Mar 7, 2025

⚠️ No Changeset found

Latest commit: aa70d75

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Mar 7, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Unverified] in Roo Code Roadmap Mar 7, 2025
Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

Thanks!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 8, 2025
@mrubens mrubens merged commit 2a65db6 into RooCodeInc:main Mar 8, 2025
16 checks passed
@github-project-automation github-project-automation bot moved this from PR [Unverified] to Done in Roo Code Roadmap Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants