🤖 fix: add trace dumps for System 1 memory writer failures#1969
Open
🤖 fix: add trace dumps for System 1 memory writer failures#1969
Conversation
b93c543 to
5f81afb
Compare
9b301d7 to
f2b2dab
Compare
f2b2dab to
ac2bd9b
Compare
Change-Id: I426dd4cd261e9433e202ecd0e486b66808995ec2 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I88cbfc5705ad9edfaecf3d85e6a7a572377986ac Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I219643590ddc44473d8a5143fa6bb5d846b064ea Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Id33f0e0fb271b639165567580b69e2473a69f991 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I62082e281752b1c882b66edf1455f8b34373f8c9 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Ia11857921ddc9bd55a69aa799aa84e1d4a7471f8 Signed-off-by: Thomas Kosiewski <tk@coder.com>
- Persist per-workspace memory writer scheduling state in the session dir - Recover from crash mid-run by treating incomplete runs as due - Add tests for restart + crash recovery Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with [`mux`](https://github.com/coder/mux) • Model: openai:gpt-5.2 • Thinking: xhigh_ Change-Id: Id0d36129afbbcdc7ad7b9d793f94b1bb114f2347
Reintroduce the Settings → System 1 section for taskSettings-backed tuning (bash output compaction + memory writer interval), without re-adding model/thinking defaults. Also wire memoryWriterIntervalMessages through the config ORPC schemas so it persists instead of being dropped. Change-Id: I5bcbd804e9faf4a34539efd8b3edb6061c2dc111 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Ie2cc52b8822ce16eb29faa822f9e6a87f9533ac1 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: If2176d7f0812b3bcd4b1d588686dc4ee89da0b70 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I33dcd899ff2f0d06e10da3f50f0fffb8db9d1c05 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I16acb3fc32ef7b68984c139b05ade57d60f92f92 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: I55ff460bc36ead2792e7f88d438b2c351b80d4d3 Signed-off-by: Thomas Kosiewski <tk@coder.com>
Change-Id: Ia51d7360c8f45a1a90e563e44c76dcd5782d78c4 Signed-off-by: Thomas Kosiewski <tk@coder.com>
ac2bd9b to
d89ca1e
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Adds richer debug visibility for the System 1 memory writer:
memory_writetool call) or times out, writes a full execution trace (prompt/messages, step results, tool executions) todebug_obj/for offline inspection.Background
We saw cases where the memory writer appeared to “not run” (no
[system1][memory]logs) or would exit withtimedOut: trueand nomemory_writecall. Most lifecycle logs were debug-only, and failures lacked enough detail to understand what the model did.Implementation
MemoryWriterPolicy: adds explicit debug logs for early-return gates; threadstriggerMessageIdinto the runner.system1MemoryWriter: captures per-attempt messages,onStepFinishresults, and tool execution records; dumps a JSON trace to~/.mux*/debug_obj/<workspaceId>/system1_memory_writer/in debug mode when the run fails to update memory.Validation
make static-checktriggerMessageIdparameterRisks
Low. Changes are scoped to debug logging and failure-path diagnostics; the writer’s normal success path is unchanged.
📋 Implementation Plan
Debug: System 1 memory writer not running / missing
[system1][memory]logsContext / Why
You set Settings → System 1 → “Write Interval (messages)” to
1, expecting the background System 1 memory writer to run after each assistant turn and update the project memory file. You’re not seeing any[system1][memory]log lines and it looks like the writer never runs.From the current code:
experiments.system1 === true) and only runs for root workspaces (it skips child/subtask workspaces).infologs are emitted by thememory_writetool when a memory file is actually written.Evidence (repo)
src/node/services/aiService.tsstores a context at stream start and callsmemoryWriterPolicy.onAssistantStreamEnd(ctx)onstream-end.src/node/services/system1/memoryWriterPolicy.tsreturns early unless:ctx.system1Enabled === true!ctx.parentWorkspaceIdinterval = config.taskSettings.memoryWriterIntervalMessages(defaults to 2)sessions/<workspaceId>/system1-memory-writer-state.json.src/browser/utils/messages/sendOptions.tspassesexperiments.system1based onisExperimentEnabled(EXPERIMENT_IDS.SYSTEM_1).src/common/orpc/schemas/stream.tsdefinesexperiments.system1in the RPC schema.src/node/services/log.tssupportsMUX_LOG_LEVEL/MUX_DEBUG.src/node/services/tools/memory_write.tslogsinfoon successful writes.src/node/services/tools/memoryCommon.tswrites to<muxHome>/memories/<projectId>.md.src/common/constants/paths.tsdefines<muxHome>:~/.mux,~/.mux-dev(whenNODE_ENV=development), orMUX_ROOT.Approach A (recommended): add explicit “no changes” debug logs (~5–20 LoC)
src/node/services/system1/memoryWriterPolicy.ts, change the existing debug line"[system1][memory] Memory writer produced no output"to something explicit like"[system1][memory] Memory writer exited without updating memory (no memory_write call)".debug(so it only appears whenMUX_LOG_LEVEL=debug/MUX_DEBUG=1).timedOut,system1Model).debuglogs on the early-return gates inonAssistantStreamEnd:ctx.system1Enabled !== true)ctx.parentWorkspaceId)MUX_LOG_LEVEL=debug(orMUX_DEBUG=1), then send a message.Approach B: user-side diagnosis (0 LoC)
1) Confirm the hard gates
experiments.system1 !== true.parentWorkspaceIdis set).stream-end. If you interrupt/abort streams, it won’t schedule.2) Confirm the interval persisted to disk
~/.mux/~/.mux-dev/(whenNODE_ENV=development)$MUX_ROOT<muxHome>/config.jsoncontains:taskSettings.memoryWriterIntervalMessages: 13) Verify scheduling without logs (state file)
Even if you can’t see stdout/stderr, the scheduler persists a state file per workspace.
workspaceId:ls -lt <muxHome>/sessions | headmetadata.jsonuntil you find the workspace you’re testing.<muxHome>/sessions/<workspaceId>/system1-memory-writer-state.jsonExpected behavior with
interval=1:lastRunStartedAtupdates (timestamp)lastRunMessageIdupdatesturnsSinceLastRunreturns to0Interpretation:
onAssistantStreamEndisn’t running (most often: System 1 experiment still OFF, or streams are aborting).lastRunStartedAtnever set → interval not being read as1, or the run is permanently “in flight”.lastRunStartedAtchanges but no memory file changes → writer ran but didn’t callmemory_write(model/tool support or credentials issue).4) Verify memory output
<muxHome>/memories/*.md.ls -lt <muxHome>/memories | head5) Enable the right logs (debug)
To see the scheduler/runner messages (which include skip reasons), you need debug logging:
MUX_LOG_LEVEL=debugorMUX_DEBUG=1Important: for the desktop app, you must start mux from a shell that has those env vars (GUI launches won’t inherit shell env). Once enabled, look for:
[system1][memory] Skipping memory writer ...[system1][memory] Memory writer completed[system1][memory] Memory writer failedDebug dumps (only in debug mode) land in:
<muxHome>/debug_obj/6) Ensure the writer’s model supports tool calling
The memory writer uses:
agentAiDefaults.system1_memory_writer.modelString(if set)ctx.modelString)If that model/provider can’t do tool calling (or lacks credentials), the writer may never call
memory_write.Actions:
system1_memory_writer(via Settings → Agents or by editingconfig.json).Why you might see “nothing” even when it’s running
Most memory-writer logs are
debug. The onlyinfoline is from thememory_writetool after the model calls it. If the model never callsmemory_write(tool calling unsupported / credentials missing / etc.), you’ll see no[system1][memory]output without enabling debug logging.Generated with
mux• Model:openai:gpt-5.2• Thinking:high• Cost:$54.20