Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(agent): steps publish their context breakdown, review notes reach the next turn (CA U3/U5 wiring)

purple02825db43c12
diff --git a/src/hooks/useAgentChat.ts b/src/hooks/useAgentChat.ts
index 4629a573..7100d74b 100644
--- a/src/hooks/useAgentChat.ts
+++ b/src/hooks/useAgentChat.ts
@@ -124,6 +124,7 @@ import {
import { setExplicitFanout, buildSubAgentGates } from '../api/agents/sub-agent'
import { appendTaskReport } from '../lib/agent-task-report'
import { appendSteers } from '../lib/agent-core/steer'
+import { publishStepBreakdown } from '../stores/contextBreakdownStore'
import { finishWithoutTools, finishSection } from '../lib/agent-core/finish'
import { useSteerStore } from '../stores/steerStore'
import { useAgentTaskStore } from '../stores/agentTaskStore'
@@ -2082,6 +2083,8 @@ export function useAgentChat() {
// it and the meter read low by the whole catalog.
if (convId) {
useSendSizeStore.getState().reportTools(convId, estimateTokens(JSON.stringify(tools)))
+ // CA U5: what this step sent, by kind, for the context breakdown.
+ publishStepBreakdown(convId, sendMessages, estimateTokens(JSON.stringify(tools)))
}
catalogTokens = estimateTokens(JSON.stringify(tools))
diff --git a/src/hooks/useCodex.ts b/src/hooks/useCodex.ts
index 743d26cf..52c33f0e 100644
--- a/src/hooks/useCodex.ts
+++ b/src/hooks/useCodex.ts
@@ -31,6 +31,7 @@ import { appendTaskReport } from '../lib/agent-task-report'
import { finishWithoutTools, finishSection } from '../lib/agent-core/finish'
import { useProviderStore } from '../stores/providerStore'
import { networkHint, runErrorKind } from '../lib/agent-core/run-error'
+import { publishStepBreakdown } from '../stores/contextBreakdownStore'
import { appendSteers } from '../lib/agent-core/steer'
import { useSteerStore } from '../stores/steerStore'
import { useAgentTaskStore } from '../stores/agentTaskStore'
@@ -134,7 +135,7 @@ import { lastRequestUsageNotice, requestUsageTracker } from '../lib/request-usag
import { shouldDowngradeThinking, engineDeniedThinking } from './codex/thinking-downgrade'
import { recoverTurnCalls } from '../lib/agent-core/recover'
import { codexStallVerdict } from './codex/stall-verdict'
-import { createStagedWriter } from './codex/staged-writes'
+import { createStagedWriter, reviewNotesText } from './codex/staged-writes'
import { codexCutoffNote, dropCutOffCall } from './codex/turn-cutoff'
import { codexToolDiff, codexEventKind } from './codex/tool-result-view'
import { capHiddenToolHistory } from './codex/hidden-history'
@@ -1004,6 +1005,17 @@ export function useCodex() {
return msg
}),
]
+ // CA U3: what the user rejected in the review since the last tool result
+ // (a change or some of its parts), in front of the new instruction, so a
+ // turn that calls no tool still learns it. Prefixed, not a turn of its
+ // own: two user turns in a row are refused by strict chat templates.
+ if (convId) {
+ const notes = useStagedChangesStore.getState().takeNotes(convId)
+ const lastUser = [...messages].reverse().find((m) => m.role === 'user')
+ if (notes.length && lastUser && typeof lastUser.content === 'string') {
+ lastUser.content = `${reviewNotesText(notes)}\n\n${lastUser.content}`
+ }
+ }
// G27b: a new turn on a conversation whose plan is still open gets the
// plan handed to it instead of being asked to find it again (the owner,
// 2026-08-22: an interrupted run left the plan lying and "continue" was
@@ -1651,6 +1663,8 @@ export function useCodex() {
stepToolsEstimate = estimateTokens(JSON.stringify(tools))
if (convId) {
useSendSizeStore.getState().reportTools(convId, stepToolsEstimate)
+ // CA U5: what this step sent, by kind, for the context breakdown.
+ publishStepBreakdown(convId, sendMessages, stepToolsEstimate)
}
diagLog('iter-start', {
iter: i,
diff --git a/src/mobile/boot/__tests__/settings-durable.test.ts b/src/mobile/boot/__tests__/settings-durable.test.ts
index 9afbf0fb..201b8ec4 100644
--- a/src/mobile/boot/__tests__/settings-durable.test.ts
+++ b/src/mobile/boot/__tests__/settings-durable.test.ts
@@ -113,6 +113,7 @@ describe('which keys are kept', () => {
'lu-neuron-tweaker': 'desktop only (3.0.9, P11): the Neuron tweaker steers LU Engine, which the phone does not have',
'lu-neuron-window': 'desktop only (3.1.0): where the Neurons window stood, a window the phone does not have',
'lu-settings-audit': 'desktop only (3.1.0, C60): what the agent changed in the desktop app; the phone has no self-control tools',
+ 'locally-uncensored-command-rules': 'desktop only (3.1.0, CA K4): commands the user allowed per folder of this computer',
'lu-chat-look': 'desktop only (3.1.0, C58): the chat look of the desktop transcript; the phone has its own chat screen',
'LU-create-orders': 'the orders of Create in chat, which is locked on the phone until it has the order card',
'lu-mobile-switched-under-answer': 'a note per answer; lost, the chat says "interrupted" instead of "you switched models"',