fix: address adversarial review findings for #3576
- Use `git reset --hard <sha>` for rollback instead of `git branch -f` which fails on checked-out branches and worktrees - Clear pendingProviderRegistrations after preflush to prevent duplicate registration when bindCore() runs - Process Ollama stream content on terminal `done:true` chunks to avoid truncating trailing assistant text
This commit is contained in:
parent
0d3ef6b545
commit
ac20eab501
3 changed files with 7 additions and 18 deletions
|
|
@ -221,9 +221,8 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|||
for (const { name, config } of extensionsForModelResolution.runtime.pendingProviderRegistrations) {
|
||||
modelRegistry.registerProvider(name, config);
|
||||
}
|
||||
// Note: we do NOT clear pendingProviderRegistrations here — bindCore() will iterate
|
||||
// an empty array harmlessly, and clearing here would require the runtime to track
|
||||
// whether the flush already happened.
|
||||
// Clear the queue so bindCore() doesn't re-register the same providers.
|
||||
extensionsForModelResolution.runtime.pendingProviderRegistrations = [];
|
||||
|
||||
// If still no model, use findInitialModel (checks settings default, then provider defaults)
|
||||
if (!model) {
|
||||
|
|
|
|||
|
|
@ -72,20 +72,10 @@ export function rollbackToCheckpoint(
|
|||
return false;
|
||||
}
|
||||
|
||||
// Reset working tree
|
||||
execFileSync("git", ["reset", "--hard"], {
|
||||
cwd: basePath,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
// Move branch pointer back to checkpoint
|
||||
execFileSync("git", ["branch", "-f", branch, sha], {
|
||||
cwd: basePath,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
|
||||
// Sync working tree with moved branch
|
||||
execFileSync("git", ["reset", "--hard"], {
|
||||
// Reset branch pointer and working tree to checkpoint SHA in one step.
|
||||
// Using `git reset --hard <sha>` works on the currently checked-out branch
|
||||
// (unlike `git branch -f` which is rejected for checked-out branches).
|
||||
execFileSync("git", ["reset", "--hard", sha], {
|
||||
cwd: basePath,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ export function streamOllamaChat(
|
|||
// Handle text content — process independently of tool_calls
|
||||
// (a chunk may contain both content and tool_calls)
|
||||
const content = chunk.message?.content ?? "";
|
||||
if (content && !chunk.done) {
|
||||
if (content) {
|
||||
if (thinkParser) {
|
||||
processChunks(thinkParser.push(content));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue