-
Notifications
You must be signed in to change notification settings - Fork 448
Proj/curation enhancement #601
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e8fa123
feat: [ENG-2518] batch abstract generation across queued files
RyanNg1403 0cf9ae5
feat: [ENG-2485] defer summary cascade to dream
RyanNg1403 0e5e1b3
refactor: [ENG-2485] address review-agent feedback on PR #579
RyanNg1403 c17a0fa
refactor: [ENG-2518] address review-agent feedback on PR #580
RyanNg1403 7838bf4
refactor: [ENG-2485] address second-pass review feedback on PR #579
RyanNg1403 887264f
refactor: [ENG-2518] address second-pass review feedback on PR #580
RyanNg1403 adda26e
Merge pull request #579 from campfirein/feat/ENG-2485
danhdoan b5c25ff
Merge branch 'proj/curation-enhancement' into feat/ENG-2518
danhdoan 3fbb17d
Merge pull request #580 from campfirein/feat/ENG-2518
danhdoan 19db5ba
feat: [ENG-2519] enable prefix caching for providers
RyanNg1403 493e848
refactor: [ENG-2519] address review-agent feedback on dateTime cache …
RyanNg1403 d51b243
Merge pull request #591 from campfirein/feat/ENG-2519
RyanNg1403 06cc5d0
feat: [ENG-2530] pre-pipeline recon to skip first agent iteration
RyanNg1403 550cc70
test: [ENG-2530] cover recon pre-pipeline wiring on curate-executor
RyanNg1403 8941d79
refactor: [ENG-2530] address review-agent feedback on PR #593
RyanNg1403 311b306
Merge pull request #593 from campfirein/feat/ENG-2530
danhdoan 1ae81cd
merge: sync main (3.10.1) into curation-enhancement
danhdoan d8c15bc
Merge pull request #599 from campfirein/chore/curation-enhancement-sy…
danhdoan 3408a3d
merge: record main 3.10.1 as integrated (resolution already landed vi…
danhdoan 0f40a05
Merge pull request #600 from campfirein/chore/curation-sync-main-3-10-1
danhdoan 7389641
Merge branch 'main' into chore/curation-sync-main
danhdoan eea396b
Merge pull request #602 from campfirein/chore/curation-sync-main
danhdoan 8b6167b
refactor: address review-agent feedback on PR #601
danhdoan 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
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 |
|---|---|---|
|
|
@@ -60,6 +60,18 @@ | |
| /** Target utilization ratio for message tokens (leaves headroom for response) */ | ||
| const TARGET_MESSAGE_TOKEN_UTILIZATION = 0.7 | ||
|
|
||
| /** | ||
| * Build a `<dateTime>...</dateTime>\n\n` prefix for a user-message body. | ||
| * | ||
| * Per-call timestamps must NOT enter the system prompt (they would poison | ||
| * the prefix cache). They are injected into the user message instead, at | ||
| * the boundaries where the model legitimately needs fresh time context: | ||
| * the iter-0 input, and after a rolling-checkpoint history clear. | ||
| */ | ||
| export function buildDateTimePrefix(now: Date = new Date()): string { | ||
| return `<dateTime>Current date and time: ${now.toISOString()}</dateTime>\n\n` | ||
| } | ||
|
|
||
| /** | ||
| * Result of parallel tool execution (before adding to context). | ||
| * Contains all information needed to add the result to context in order. | ||
|
|
@@ -198,7 +210,7 @@ | |
| * | ||
| * @param sessionId - Unique identifier for this session | ||
| * @param generator - Content generator for LLM calls (with decorators pre-applied) | ||
| * @param config - LLM service configuration (model, tokens, temperature) | ||
|
Check warning on line 213 in src/agent/infra/llm/agent-llm-service.ts
|
||
| * @param options - Service dependencies | ||
| * @param options.toolManager - Tool manager for executing agent tools | ||
| * @param options.systemPromptManager - System prompt manager for building system prompts | ||
|
|
@@ -902,8 +914,11 @@ | |
| this.cachedBasePrompt = basePrompt | ||
| this.memoryDirtyFlag = false | ||
| } else { | ||
| // Cache hit: reuse base prompt, only refresh the DateTime section | ||
| basePrompt = this.refreshDateTime(this.cachedBasePrompt!) | ||
| // Cache hit: reuse base prompt verbatim. The cached prompt has no | ||
| // dateTime section to refresh — dateTime is injected into the | ||
| // first user message instead so the system prefix stays byte-stable | ||
| // across iterations and prompt caching can engage cleanly. | ||
| basePrompt = this.cachedBasePrompt! | ||
| } | ||
|
|
||
| let systemPrompt = basePrompt | ||
|
|
@@ -944,9 +959,13 @@ | |
|
|
||
| // Add user message and compress context within mutex lock | ||
| return this.mutex.withLock(async () => { | ||
| // Add user message to context only on the first iteration | ||
| // Add user message to context only on the first iteration. The | ||
| // dateTime block is prefixed here (not in the system prompt) so | ||
| // the cached system prefix stays byte-stable across iterations | ||
| // and Anthropic/OpenAI/Google prefix caches can engage cleanly. | ||
| if (iterationCount === 0) { | ||
| await this.contextManager.addUserMessage(textInput, imageData, fileData) | ||
| const inputWithDateTime = `${buildDateTimePrefix()}${textInput}` | ||
| await this.contextManager.addUserMessage(inputWithDateTime, imageData, fileData) | ||
| } | ||
|
|
||
| // Rolling checkpoint: periodically save progress and clear history for RLM commands. | ||
|
|
@@ -1540,8 +1559,12 @@ | |
| // Clear conversation history | ||
| await this.contextManager.clearHistory() | ||
|
|
||
| // Re-inject continuation prompt with variable reference | ||
| const continuationPrompt = [ | ||
| // Re-inject continuation prompt with variable reference. | ||
| // Prepend the dateTime block: clearHistory wiped the iter-0 user | ||
| // message that originally carried it, and the iter-0 guard upstream | ||
| // prevents re-injection. Without this, every iteration after the | ||
| // first checkpoint loses time context for the rest of the run. | ||
| const continuationPrompt = buildDateTimePrefix() + [ | ||
| `Continue task. Iteration checkpoint at turn ${iterationCount}.`, | ||
| `Previous progress stored in variable: ${checkpointVar}`, | ||
| `Original task: ${textInput.slice(0, 200)}${textInput.length > 200 ? '...' : ''}`, | ||
|
|
@@ -1555,19 +1578,6 @@ | |
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Replace the DateTime section in a cached system prompt with a fresh timestamp. | ||
| * DateTimeContributor wraps its output in <dateTime>...</dateTime> XML tags, | ||
| * enabling reliable regex replacement without rebuilding the entire prompt. | ||
| * | ||
| * @param cachedPrompt - Previously cached system prompt | ||
| * @returns Updated prompt with fresh DateTime | ||
| */ | ||
| private refreshDateTime(cachedPrompt: string): string { | ||
| const freshDateTime = `<dateTime>Current date and time: ${new Date().toISOString()}</dateTime>` | ||
| return cachedPrompt.replace(/<dateTime>[\S\s]*?<\/dateTime>/, freshDateTime) | ||
| } | ||
|
|
||
| /** | ||
| * Check if a rolling checkpoint should trigger. | ||
| * Triggers every N iterations for curate/query commands, or when token utilization is high. | ||
|
|
||
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
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.