fix: filter non-JSON log messages from ACP agent output#160
Open
gandli wants to merge 5 commits intoopenclaw:mainfrom
Open
fix: filter non-JSON log messages from ACP agent output#160gandli wants to merge 5 commits intoopenclaw:mainfrom
gandli wants to merge 5 commits intoopenclaw:mainfrom
Conversation
- Add filterAcpOutputStream() to filter out non-JSON lines from agent stdout before ndJsonStream parsing - Add isValidAcpMessage() check in createTappedStream() as additional safety layer - Prevents '[iFlow ACP Agent] ...' style log messages from causing JSON parse errors in @agentclientprotocol/sdk Fixes integration with iflow CLI and other ACP agents that output log messages to stdout/stderr.
This hook automatically removes any Co-authored-by lines from commit messages, preventing AI assistants from adding their signature to commits.
- Remove unused 'parsed' variable in filterAcpOutputStream() - Keep JSON.parse() call for validation but don't assign to variable
- Add fail-fast mechanism: throw error after 10 consecutive non-JSON lines to detect adapters that don't support stdio ACP mode - Flush buffered content at EOF to handle final JSON-RPC frame without trailing newline - Reset non-JSON counter after successful JSON parse to allow occasional log lines Addresses: - P2: Fail fast on stdout protocol violations - P2: Flush the buffered final frame at EOF
The global git template at ~/.git-templates/hooks/commit-msg will handle removing Co-authored-by lines for all repositories.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
acpx fails to integrate with iflow CLI due to JSON parse errors when the agent outputs log messages like:
Root Cause
iflow CLI outputs initialization log messages to stdout/stderr during startup. These non-JSON lines are passed to
@agentclientprotocol/sdk'sndJsonStreamparser, which attempts to parse them as JSON and fails.Solution
Added two-layer filtering to prevent non-JSON log messages from breaking the ACP protocol stream:
filterAcpOutputStream()- New method that filters the output stream beforendJsonStreamparsing, with:isValidAcpMessage()- Additional validation layer increateTappedStream()Testing
acpx iflow sessions newnow works without JSON parse errorsImpact
Fixes integration with iflow CLI and other ACP agents that output initialization log messages to stdout/stderr during startup.
Codex Review Addressed