Skip to content

Improve injection logic and add defensive array checks#307

Merged
Tarquinen merged 3 commits intodevfrom
feature/injection-and-defensive-checks
Jan 22, 2026
Merged

Improve injection logic and add defensive array checks#307
Tarquinen merged 3 commits intodevfrom
feature/injection-and-defensive-checks

Conversation

@Tarquinen
Copy link
Collaborator

@Tarquinen Tarquinen commented Jan 22, 2026

Summary

  • Add defensive Array.isArray() checks before iterating over msg.parts to prevent runtime errors
  • Update injection logic to create a synthetic user message when the last message is from the user (instead of skipping injection entirely), closes Error: Invalid IDs provided. Only use numeric IDs from the <prunable-tools> list. #305
  • Update prompt wording to be consistent with new behavior ("turn" instead of "assistant turn", "synthetic message" instead of "assistant message")
  • Make discard tool spec guidance tool-agnostic (removes reference to extract tool)

Prevent runtime errors when msg.parts is undefined or not an array
by using Array.isArray() guard before iteration.
- Add createSyntheticUserMessage helper function
- Update injection logic to create user message when appropriate
  instead of skipping injection entirely
- Update prompt wording: 'assistant turn' -> 'turn',
  'assistant message' -> 'synthetic message'
- Make discard tool spec guidance tool-agnostic
@Tarquinen Tarquinen merged commit 57dfd50 into dev Jan 22, 2026
1 check passed
@Tarquinen Tarquinen deleted the feature/injection-and-defensive-checks branch January 22, 2026 01:33
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.

1 participant

Comments