Skip to content

Conversation

@sr-tream
Copy link
Contributor

Refactor isAgentCall logic to check only the last message in the history rather than any message. This prevents valid user messages from being incorrectly flagged as agent calls due to previous assistant history, ensuring proper credit consumption for multi-turn conversations.

Fixes #9

Copilot AI review requested due to automatic review settings January 10, 2026 03:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in credit consumption for chat messages where subsequent user messages in multi-turn conversations were incorrectly flagged as agent calls, preventing proper credit deduction. The fix changes the isAgentCall detection logic to examine only the last message in the conversation history instead of checking all messages.

Changes:

  • Modified isAgentCall detection to check only the last message in the body.messages array instead of using some() to check all messages
  • Added defensive check to ensure messages array is not empty before accessing the last element
  • Aligned the logic with the existing pattern used for body.input handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Refactor `isAgentCall` logic to check only the last message in the history rather than any message. This prevents valid user messages from being incorrectly flagged as agent calls due to previous assistant history, ensuring proper credit consumption for multi-turn conversations.

Fixes #9
@sr-tream sr-tream force-pushed the fix-credits-consume branch from 081ed39 to ab3c902 Compare January 10, 2026 04:07
@joseehilton147
Copy link

+1 on this, merge please

@rekram1-node rekram1-node merged commit 8e2d72d into anomalyco:main Jan 11, 2026
@rekram1-node
Copy link
Contributor

ill release later today

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.

Inconsistent credit consumption in OpenCode chat compared to VS Code Copilot

3 participants