Skip to content

Conversation

@code-yeongyu
Copy link
Contributor

Summary

  • Fix hardcoded agent: "general" in injectCompactionContext to respect the actual agent from previous messages

Problem

When compaction context is injected via injectHookMessage, the agent is hardcoded as "general":

const success = injectHookMessage(summarizeCtx.sessionID, prompt, {
  agent: "general",  // ← Always "general", ignoring actual agent
  model: { providerID: summarizeCtx.providerID, modelID: summarizeCtx.modelID },
  path: { cwd: summarizeCtx.directory },
});

This causes the compaction context message to be attributed to "general" agent instead of the actual agent (e.g., "Sisyphus", "oracle") that was active when compaction was triggered.

Solution

Remove the hardcoded agent: "general" and let injectHookMessage's existing fallback logic handle it:

// Line 192 in injectHookMessage already has:
const resolvedAgent = originalMessage.agent ?? fallback?.agent ?? "general";

By not passing an explicit agent, injectHookMessage will:

  1. Check originalMessage.agent (undefined)
  2. Fall back to findNearestMessageWithFields to get the actual agent from stored messages
  3. Only use "general" as a last resort

This is a 1-line fix that leverages existing fallback logic.

Testing

  • Build passes (bun run build)
  • No breaking changes to existing interfaces

The correct hook name is 'anthropic-context-window-limit-recovery', not 'anthropic-auto-compact'.

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
Also update CLI flag from --disable-auto-compact to --disable-context-recovery
to match the new hook naming convention.

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
Remove hardcoded 'agent: "general"' from injectCompactionContext.
The injectHookMessage function already has fallback logic that uses
findNearestMessageWithFields to get the actual agent from previous messages.

By not passing an explicit agent, we allow the existing fallback to work:
  resolvedAgent = originalMessage.agent ?? fallback?.agent ?? "general"

This ensures the compaction context message is correctly attributed to the
agent that was active when compaction was triggered, maintaining proper
agent context across session compaction.

🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
@code-yeongyu code-yeongyu force-pushed the fix/respect-agent-on-compaction-context-injection branch from ff7f461 to 63c1c61 Compare January 1, 2026 11:19
Copy link
Member

@nexxeln nexxeln left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great thanks!

@nexxeln nexxeln merged commit a28a02c into supermemoryai:main Jan 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants