feat(claude_sdk): add CSDK-019, tool prints to stdout for diagnostics - #83
Open
bradAGI wants to merge 1 commit into
Open
feat(claude_sdk): add CSDK-019, tool prints to stdout for diagnostics#83bradAGI wants to merge 1 commit into
bradAGI wants to merge 1 commit into
Conversation
Claude SDK and MCP were the two mature packs with no observability rule; OpenAI ships OAI-010 and ADK ships ADK-009 for the same pattern. Two Claude-SDK-specific consequences go beyond the lost log line OAI-010 describes. A tool defined in a Python SDK server is commonly served to the agent over an MCP stdio transport, where stdout carries the JSON-RPC frames and a loose print makes the client hit a parse error on a line that is not JSON. And when the SDK is driven programmatically, the host application is already reading the SDK's own message stream, so tool prints land interleaved with it rather than in the application's logs, attributable to no particular turn or tool call.
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.
Claude SDK and MCP were the two mature packs with no observability rule. OpenAI ships OAI-010 and ADK ships ADK-009 for the same
print()pattern.Two Claude-SDK-specific consequences go beyond the lost-log-line framing OAI-010 uses:
The fix reflects the first point: where the tool may be served over stdio, the log handler needs to write to stderr, which the transport leaves alone. Swapping
printfor a logger that still defaults to stdout doesn't fix that case.Severity/confidence match OAI-010 (
low/ 0.65) since the dominant case here is still the lost diagnostic. The sharper stdio-corruption case is the primary reading in MCP-023 (#82), where stdio is the default transport.Verification — engine built at
main:Fire (
print(...)in a@tool-decorated handler):CSDK-002, CSDK-019, CSDK-203Silent (
logger.info(...)withbasicConfig(stream=sys.stderr)):CSDK-002, CSDK-203(CSDK-002 and CSDK-203 are pre-existing rules firing on the fixture's untyped
argsparam and missing CLAUDE.md.)has_print_callmatches a bareprintcallee, sopprintand other attribute calls don't false-positive.No new predicates, so no
schema_versionbump.