Reddit

RedditTools enables agents to interact with Reddit for browsing posts, comments, and subreddit information.

Example

The following agent can browse and analyze Reddit content:

1from kern.agent import Agent
2from kern.tools.reddit import RedditTools
3
4agent = Agent(
5 instructions=[
6 "You are a Reddit content analyst that helps explore and understand Reddit data",
7 "Browse subreddits, analyze posts, and provide insights about discussions",
8 "Respect Reddit's community guidelines and rate limits",
9 "Provide clear summaries of Reddit content and trends",
10 ],
11 tools=[RedditTools()],
12)
13
14agent.print_response("Show me the top posts from r/technology today", stream=True)

Toolkit Params

ParameterTypeDefaultDescription
reddit_instanceOptional[praw.Reddit]NoneExisting Reddit instance to use.
client_idOptional[str]NoneReddit client ID. Uses REDDIT_CLIENT_ID if not set.
client_secretOptional[str]NoneReddit client secret. Uses REDDIT_CLIENT_SECRET if not set.
user_agentOptional[str]"RedditTools v1.0"User agent string for API requests.
usernameOptional[str]NoneReddit username for authenticated access.
passwordOptional[str]NoneReddit password for authenticated access.

Toolkit Functions

FunctionDescription
get_subreddit_infoGet information about a specific subreddit.
get_subreddit_postsGet posts from a subreddit with various sorting options.
search_subredditsSearch for subreddits by name or topic.
get_post_detailsGet detailed information about a specific post.
get_post_commentsGet comments from a specific post.
search_postsSearch for posts across Reddit or within subreddits.
get_user_infoGet information about a Reddit user.
get_user_postsGet posts submitted by a specific user.
get_user_commentsGet comments made by a specific user.
create_postCreate a new post (requires authentication).
create_commentCreate a comment on a post (requires authentication).
vote_on_postVote on a post (requires authentication).
vote_on_commentVote on a comment (requires authentication).

You can use include_tools or exclude_tools to modify the list of tools the agent has access to. Learn more about selecting tools.

Developer Resources