Skip to content

Conversation

@Tarquinen
Copy link
Collaborator

@Tarquinen Tarquinen commented Jan 6, 2026

  • Removes the isInternalAgent flag from session state
  • Fixes race condition where concurrent internal agents (title/summary generators) would cause the prunable-tools list to not be injected

The messages.transform hook runs before system.transform, but we were setting isInternalAgent in system.transform. When concurrent internal agents ran, the flag would be stale by the time the next normal session's messages.transform checked it, causing it to skip insertPruneToolContext().

Need a better solution to stop injections for internal agents

The isInternalAgent flag was causing a race condition where concurrent
internal agents (title/summary generators) would set the flag to true,
and normal session message transforms would see the stale value and skip
injecting the prunable-tools list.

This happened because messages.transform runs before system.transform,
so the flag set by system.transform was always stale by the time
messages.transform checked it.

Fix: Remove the flag entirely and only skip system prompt injection for
internal agents (detected in system.transform where it works reliably).
@Tarquinen Tarquinen merged commit ed19cb2 into dev Jan 6, 2026
1 check passed
@Tarquinen Tarquinen deleted the fix/remove-internal-agent-flag branch January 6, 2026 18:52
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