Skip to content

Fix get_post_content silently dropping comment_depth#9

Open
johntrandall wants to merge 1 commit into
Hawstein:mainfrom
johntrandall:fix/comment-depth-pass-through
Open

Fix get_post_content silently dropping comment_depth#9
johntrandall wants to merge 1 commit into
Hawstein:mainfrom
johntrandall:fix/comment-depth-pass-through

Conversation

@johntrandall

@johntrandall johntrandall commented May 1, 2026

Copy link
Copy Markdown

What this changes

Three-line fix in src/mcp_server_reddit/server.py: thread comment_depth
from get_post_content through get_post_comments into _build_comment_tree.

 def get_post_content(self, post_id, comment_limit=10, comment_depth=3):
     ...
-    comments = self.get_post_comments(post_id, comment_limit)
+    comments = self.get_post_comments(post_id, comment_limit, depth=comment_depth)

-def get_post_comments(self, post_id, limit=10):
+def get_post_comments(self, post_id, limit=10, depth=3):
     ...
-    comment_tree = self._build_comment_tree(node)
+    comment_tree = self._build_comment_tree(node, depth=depth)

Why

get_post_content accepts comment_depth from the client and call_tool forwards it, but the call to get_post_comments drops the argument, so _build_comment_tree always falls back to its default depth=3. Net effect: the user-supplied comment_depth has no effect — threads silently truncate at 3 levels regardless of the requested depth.

Tests

tests/test_comment_depth.py — three regressions, all pass:

  • test_get_post_comments_default_depth_is_3 — default unchanged
  • test_get_post_comments_respects_depth_arg — depth propagates inside get_post_comments
  • test_get_post_content_propagates_comment_depth — bug site: get_post_content passes the right args downstream

Verified empirically against a Reddit thread where comment_depth=10 previously returned the same truncated tree as the default; after the fix the full chain comes back.

🤖 Generated with Claude Code

get_post_content accepts a comment_depth parameter, but inside the
function the call to get_post_comments dropped it. get_post_comments
then called _build_comment_tree(node) with no depth argument, defaulting
to 3 every time — so the user-supplied comment_depth had no effect and
threads silently truncated at depth 3.

Symptom: callers pass comment_depth=10 expecting deep threads; tree
truncates at 3 regardless. Found while sweeping a Reddit thread where
the answer to a user's question lived at depth 4.

Fix: thread depth through get_post_comments and into the recursion.

Adds three regression tests covering the default, the propagation
through get_post_comments, and the bug-site propagation through
get_post_content.

Claude-Session-Id: $CLAUDE_SESSION_ID
Resume: claude --resume $CLAUDE_SESSION_ID
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