feat: implement automatic temperature reduction on tool failure #6158
+466
−605
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements automatic temperature reduction when tool use fails, as requested in issue #6156.
Changes
Added temperature tracking properties to the Task class:
currentTemperature
: Tracks the current temperature valueoriginalTemperature
: Stores the initial temperature for restorationtemperatureReductionAttempts
: Counts reduction attempts (max 3)shouldRetryWithReducedTemperature
: Flag to trigger temperature reductionImplemented temperature reduction logic:
Added comprehensive test coverage:
Testing
All tests pass successfully. The new test file
Task.temperature.spec.ts
provides comprehensive coverage of the temperature reduction functionality.Related Issue
Fixes #6156
Important
Implements automatic temperature reduction on tool failure in
Task
class, with retries and comprehensive test coverage.Task
class when tool use fails, reducing by 0.5 factor, retrying up to 3 times.presentAssistantMessage()
.currentTemperature
,originalTemperature
,temperatureReductionAttempts
,shouldRetryWithReducedTemperature
toTask
.attemptApiRequest()
to accept temperature override.retryWithReducedTemperature()
to handle retry logic.recordToolError()
to set retry flag.Task.temperature.spec.ts
for testing temperature reduction logic, covering initialization, reduction, retry limits, and edge cases.This description was created by
for abff598. You can customize this summary. It will automatically update as commits are pushed.