Skip to content

fix: only check last message for agent call #741

Closed
mhuggins7278 wants to merge 3 commits into
anomalyco:devfrom
mhuggins7278:copilot-agent-fixes
Closed

fix: only check last message for agent call #741
mhuggins7278 wants to merge 3 commits into
anomalyco:devfrom
mhuggins7278:copilot-agent-fixes

Conversation

@mhuggins7278

Copy link
Copy Markdown
Contributor

This improves agent call detection by only checking the last message role, reducing false positives.

🤖 Generated with opencode

Co-Authored-By: opencode noreply@opencode.ai

@adamdotdevin

Copy link
Copy Markdown
Member

we can get this merged if you can rebase

…ves agent call detection by only checking the last message role, reducing false positives.\n\n🤖 Generated with [opencode](https://opencode.ai)\n\nCo-Authored-By: opencode <noreply@opencode.ai>
@mhuggins7278
mhuggins7278 force-pushed the copilot-agent-fixes branch from 9108526 to ec73a4c Compare July 9, 2025 16:54
@mhuggins7278

Copy link
Copy Markdown
Contributor Author

done

no need for the nested if here
teamgroove pushed a commit to teamgroove/opencode that referenced this pull request Aug 3, 2025
Merged from: anomalyco#741
Author: @mhuggins7278
Auto-merged by opencode-fork integration system

@danriedl danriedl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd propose a rebase because of the fix commit.

const lastMessage = body.messages[body.messages.length - 1]
isAgentCall = lastMessage.role && ["tool", "assistant"].includes(lastMessage.role)
//NOTE: Should this also use lastMessage or given the vision
//flow does this even matter

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

those comments are not very helpful

@mhuggins7278

Copy link
Copy Markdown
Contributor Author

@adamdotdevin I rebased this a while ago. Still something I think should be merged. I would hate to get the tool blacklisted. Currently only user requests up to the first tool call are getting counted as usage against the GH premium request limits.

@mhuggins7278
mhuggins7278 requested a review from danriedl August 11, 2025 19:43
andreipromarketing-dev pushed a commit to andreipromarketing-dev/opencode that referenced this pull request Apr 7, 2026
…o#741)

* fix(hooks): collapse multi-line commands in bash audit logs

Add gsub("\\n"; " ") to jq filters in bash audit log and cost-tracker
hooks so multi-line commands produce single-line log entries, preventing
breakage in downstream line-based parsing.

Fixes anomalyco#734

* fix: forward stdin to downstream hooks using echo pattern

Addresses review feedback: PostToolUse hooks now preserve stdin
for subsequent hooks by echoing $INPUT back to stdout after
processing. Changed ; to && for proper error propagation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: make stdin passthrough unconditional and broaden secret redaction

- Use semicolons instead of && so printf passthrough always runs
  even if jq fails
- Add || true after jq to prevent non-zero exit on parse errors
- Use printf '%s\n' instead of echo for safe binary passthrough
- Fix Authorization pattern to handle 'Bearer <token>' with space
- Add ASIA (STS temp credentials) alongside AKIA redaction
- Add GitHub token patterns (ghp_, gho_, ghs_, github_pat_)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use [: ]* instead of s* for Authorization whitespace matching

jq's ONIG regex engine interprets s* as literal 's' zero-or-more,
not \s* (whitespace). This caused 'Authorization: Bearer <token>'
to only redact 'Authorization:' and leak the actual token.

Using [: ]* avoids the JSON/jq double-escape issue entirely and
correctly matches both 'Authorization: Bearer xyz' and
'Authorization:xyz' patterns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bussard76 pushed a commit to bussard76/openwork that referenced this pull request May 12, 2026
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.

3 participants