Repository navigation
feat(task): task-local runtime thinking effort state with per-request override (DTE series 2/5) #1523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
easonLiangWorldedtech
wants to merge
1
commit into
Zoo-Code-Org:main
Choose a base branch
from
easonLiangWorldedtech:feat/dte-v2-3-task-runtime-effort
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat(task): task-local runtime thinking effort state with per-request override (DTE series 2/5) #1523
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/core/condense/__tests__/condense-effort-metadata.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // npx vitest run src/core/condense/__tests__/condense-effort-metadata.spec.ts | ||
| // | ||
| // The summarizer boundary: Task hands the task-local thinking effort override to | ||
| // to summarizeConversation inside request metadata. This checks the other half of that hand-off: | ||
| // the real summarizer forwards the metadata to the handler's createMessage instead of dropping | ||
| // the effort. The Task-side tests cover Task-to-summarizer propagation only. | ||
|
|
||
| import { Anthropic } from "@anthropic-ai/sdk" | ||
| import type { ModelInfo, ReasoningEffortExtended } from "@roo-code/types" | ||
| import { TelemetryService } from "@roo-code/telemetry" | ||
|
|
||
| import type { ApiHandlerCreateMessageMetadata } from "../../../api" | ||
| import { BaseProvider } from "../../../api/providers/base-provider" | ||
| import { ApiStream, ApiStreamChunk } from "../../../api/transform/stream" | ||
| import { ApiMessage } from "../../task-persistence/apiMessages" | ||
| import { summarizeConversation } from "../index" | ||
|
|
||
| const OVERRIDE_EFFORT: ReasoningEffortExtended = "xhigh" | ||
| const TASK_ID = "dte-condense-task" | ||
|
|
||
| class RecordingApiHandler extends BaseProvider { | ||
| /** The metadata of the last request this handler was asked to make. */ | ||
| public requestedMetadata: ApiHandlerCreateMessageMetadata | undefined | ||
|
|
||
| override createMessage( | ||
| _systemPrompt: string, | ||
| _messages: Anthropic.Messages.MessageParam[], | ||
| metadata?: ApiHandlerCreateMessageMetadata, | ||
| ): ApiStream { | ||
| this.requestedMetadata = metadata | ||
| return (async function* (): AsyncGenerator<ApiStreamChunk> { | ||
| yield { type: "text", text: "summary of the conversation" } | ||
| yield { type: "usage", inputTokens: 10, outputTokens: 5, totalCost: 0.01 } | ||
| })() | ||
| } | ||
|
|
||
| override getModel(): { id: string; info: ModelInfo } { | ||
| return { | ||
| id: "dte-condense-model", | ||
| info: { contextWindow: 100_000, maxTokens: 5_000, supportsPromptCache: false, supportsImages: false }, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Three messages with no summary in them: getMessagesSinceLastSummary returns all of them, so | ||
| // summarizeConversation gets past its "not enough messages" guard and issues the request. | ||
| function conversationHistory(): ApiMessage[] { | ||
| return [ | ||
| { role: "user", content: [{ type: "text", text: "read the failing test" }], ts: 1 }, | ||
| { role: "assistant", content: [{ type: "text", text: "the assertion drifted" }], ts: 2 }, | ||
| { role: "user", content: [{ type: "text", text: "fix it" }], ts: 3 }, | ||
| ] | ||
| } | ||
|
|
||
| describe("summarizeConversation reasoning-effort forwarding", () => { | ||
| beforeEach(() => { | ||
| if (!TelemetryService.hasInstance()) { | ||
| TelemetryService.createInstance([]) | ||
| } | ||
| }) | ||
|
|
||
| it("forwards an active override to the handler request", async () => { | ||
| const handler = new RecordingApiHandler() | ||
|
|
||
| const result = await summarizeConversation({ | ||
| messages: conversationHistory(), | ||
| apiHandler: handler, | ||
| systemPrompt: "system prompt", | ||
| taskId: TASK_ID, | ||
| isAutomaticTrigger: false, | ||
| metadata: { mode: "code", taskId: TASK_ID, reasoningEffort: OVERRIDE_EFFORT }, | ||
| environmentDetails: "environment details", | ||
| cwd: "/workspace", | ||
| }) | ||
|
|
||
| expect(result.error).toBeUndefined() | ||
| expect(result.summary).toBe("summary of the conversation") | ||
| expect(handler.requestedMetadata?.reasoningEffort).toBe(OVERRIDE_EFFORT) | ||
| }) | ||
|
|
||
| it("omits the key when the caller hands no override", async () => { | ||
| const handler = new RecordingApiHandler() | ||
|
|
||
| const result = await summarizeConversation({ | ||
| messages: conversationHistory(), | ||
| apiHandler: handler, | ||
| systemPrompt: "system prompt", | ||
| taskId: TASK_ID, | ||
| isAutomaticTrigger: false, | ||
| metadata: { mode: "code", taskId: TASK_ID }, | ||
| environmentDetails: "environment details", | ||
| cwd: "/workspace", | ||
| }) | ||
|
|
||
| expect(result.summary).toBe("summary of the conversation") | ||
| expect(handler.requestedMetadata).not.toHaveProperty("reasoningEffort") | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.