Skip to content

feat(templates): add Discord Community Digest agent template#6343

Open
Ttian18 wants to merge 1 commit intoaden-hive:mainfrom
Ttian18:feat/tina/discord-digest-template
Open

feat(templates): add Discord Community Digest agent template#6343
Ttian18 wants to merge 1 commit intoaden-hive:mainfrom
Ttian18:feat/tina/discord-digest-template

Conversation

@Ttian18
Copy link
Copy Markdown
Contributor

@Ttian18 Ttian18 commented Mar 14, 2026

Closes #5342

Summary

  • New 3-node template agent: configure → scan-channels → generate-digest
  • Scans Discord servers, categorizes messages by priority (Action Needed / Interesting Threads / Announcements / FYI), and delivers a digest to a designated channel
  • Uses repo's built-in discord tools — no custom discord_client.py
  • Per-channel dedup cursor (load_data/save_data) to avoid repeating messages on reruns
  • One-shot pipeline with configurable lookback window (1-7 days)
  • Single credential: DISCORD_BOT_TOKEN

Test plan

  • ruff check and ruff format --check pass
  • default_agent.validate() passes
  • GraphSpec.validate() passes with no errors
  • AgentRunner.load() succeeds
  • All 3 nodes reachable from entry, terminal node correct
  • Data flow verified: all node input_keys satisfied by predecessors
  • Dedup cursor: scan node has load_data + save_data tools and prompt instructions
  • No hardcoded channel IDs, user IDs, or model names
  • Code style matches existing template agents
  • hive open --agent examples/templates/discord_digest loads correctly (health check OK, session created)
  • 75 structural tests passed

Summary by CodeRabbit

  • New Features
    • Added Discord Community Digest agent template as a complete example
    • Monitor Discord servers, categorize messages by priority, and deliver community activity summaries
    • CLI interface with run, info, and validate commands for agent management and configuration verification

- 3-node pipeline: configure → scan-channels → generate-digest
- Uses repo's built-in discord tools (list_guilds, list_channels,
  get_messages, send_message)
- Per-channel dedup cursor via load_data/save_data to avoid
  duplicate messages on reruns
- Digest categories: Action Needed, Interesting Threads,
  Announcements, FYI
- Delivery to user-specified Discord channel
- One-shot pipeline (terminal_nodes = ["generate-digest"])
@Ttian18 Ttian18 force-pushed the feat/tina/discord-digest-template branch from e1001c4 to 82b41fe Compare March 30, 2026 21:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

A new Discord Community Digest agent template is added, implementing a 3-node linear pipeline that scans Discord servers, categorizes messages by priority, and delivers summaries. The template includes the agent class, graph definition, three node specifications, CLI tooling, configuration, and MCP server setup.

Changes

Cohort / File(s) Summary
Package Structure
examples/templates/discord_digest/__init__.py
Package entry point re-exporting DiscordDigestAgent, agent graph components (goal, nodes, edges, entry_node, entry_points, pause_nodes, terminal_nodes), runtime parameters (conversation_mode, identity_prompt, loop_config), and configuration (default_config, metadata) via explicit __all__ list.
Agent Core
examples/templates/discord_digest/agent.py
Defines DiscordDigestAgent class managing graph construction, runtime setup (tool registry, checkpoint storage, LiteLLMProvider), and lifecycle (start/stop/trigger_and_wait/run). Declares goal with success criteria and constraints. Exports default_agent instance.
Node Definitions
examples/templates/discord_digest/nodes/__init__.py
Three NodeSpec nodes: configure_node (client-facing, outputs digest_config), scan_channels_node (scans Discord channels within lookback window, flags messages), generate_digest_node (categorizes and delivers digest via Discord DM).
Configuration & Metadata
examples/templates/discord_digest/config.py
Introduces default_config (RuntimeConfig instance) and AgentMetadata dataclass with name, version, description, and intro_message fields.
CLI Entry Point
examples/templates/discord_digest/__main__.py
Click command group with run (executes agent, returns JSON), info (prints agent metadata), and validate (verifies graph structure) subcommands. Includes setup_logging() for verbosity control.
MCP Server Configuration
examples/templates/discord_digest/mcp_servers.json
Registers hive-tools MCP server via stdio transport, configured to run mcp_server.py from tools directory.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as CLI Interface
    participant Agent as DiscordDigestAgent
    participant Runtime as Agent Runtime
    participant ConfigNode as configure_node
    participant ScanNode as scan_channels_node
    participant DiscordAPI as Discord API
    participant GenNode as generate_digest_node

    User->>CLI: Run agent with --run flag
    CLI->>Agent: start()
    Agent->>Runtime: create_agent_runtime()
    Agent->>Runtime: initialize with checkpoint storage
    
    Runtime->>ConfigNode: trigger entry point "default"
    ConfigNode->>ConfigNode: collect user preferences (servers, lookback window, keywords)
    ConfigNode-->>Runtime: output digest_config
    
    Runtime->>ScanNode: execute with digest_config
    ScanNode->>DiscordAPI: discord_list_guilds()
    ScanNode->>DiscordAPI: discord_list_channels()
    ScanNode->>DiscordAPI: discord_get_messages(within lookback window)
    ScanNode->>ScanNode: flag mentions, replies, admin posts, high-engagement
    ScanNode-->>Runtime: output channel_data
    
    Runtime->>GenNode: execute with digest_config + channel_data
    GenNode->>GenNode: categorize messages (Action Needed, Interesting Threads, Announcements, FYI)
    GenNode->>DiscordAPI: discord_send_message(digest summary as DM)
    GenNode-->>Runtime: output digest_report
    
    Runtime-->>Agent: execution complete
    Agent->>Agent: stop()
    CLI-->>User: return ExecutionResult (success + output)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hop, hop, a Discord digest flows,
Where messages gather, priority shows!
Scan, sort, and summarize with care,
No more chaos in the channel square! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a Discord Community Digest agent template, directly aligning with the primary objective.
Linked Issues check ✅ Passed The implementation fully addresses all coding requirements from #5342: 3-node pipeline with configure→scan-channels→generate-digest, use of existing Discord tools, message categorization, per-channel deduplication, configurable lookback window, and single credential requirement.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the Discord Community Digest template. No unrelated modifications to existing codebase or out-of-scope additions detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (4)
examples/templates/discord_digest/nodes/__init__.py (1)

1-4: Consider adding from __future__ import annotations.

Per coding guidelines for Python files.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/nodes/__init__.py` around lines 1 - 4, Add
the future annotations import to the module by inserting "from __future__ import
annotations" at the top of the file before any other imports or module-level
code (the file containing the module docstring and the import of NodeSpec from
framework.graph). This ensures forward-compatible type annotations in the module
that defines the Discord Community Digest nodes (referenced symbol: NodeSpec)
and follows the project coding guidelines.
examples/templates/discord_digest/config.py (1)

1-7: Consider adding from __future__ import annotations for modern type syntax.

Per coding guidelines, this import is recommended for Python files to enable modern type annotation syntax.

Suggested fix
 """Runtime configuration for Discord Community Digest."""
 
+from __future__ import annotations
+
 from dataclasses import dataclass
 
 from framework.config import RuntimeConfig
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/config.py` around lines 1 - 7, Add "from
__future__ import annotations" as the first import in this module to enable
postponed evaluation of annotations and modern type syntax; update the top of
the file before any other imports (which currently include dataclass and
RuntimeConfig) so that dataclass usage and the RuntimeConfig instantiation
(default_config = RuntimeConfig()) benefit from future annotations.
examples/templates/discord_digest/__main__.py (1)

23-27: Version is duplicated — consider importing from metadata.

The version "1.0.0" is hardcoded here and also defined in config.py as AgentMetadata.version. This violates DRY and can lead to version drift.

Suggested fix
+from .config import metadata
+
 `@click.group`()
-@click.version_option(version="1.0.0")
+@click.version_option(version=metadata.version)
 def cli():
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/__main__.py` around lines 23 - 27, Replace
the hardcoded version string in the click.version_option decorator with the
centralized version constant; import AgentMetadata (or the module exporting
version) and use AgentMetadata.version in the click.version_option call inside
the cli function so the CLI version matches the project's single source of truth
(refer to the cli function and the click.version_option usage and the
AgentMetadata.version symbol).
examples/templates/discord_digest/agent.py (1)

1-19: Add from __future__ import annotations and consolidate framework.graph imports.

The GraphSpec import from framework.graph.edge (line 6) should be consolidated with other framework.graph imports (line 5) for consistency. Add the future annotations import at the top to enable modern type syntax.

Suggested fix
 """Agent graph construction for Discord Community Digest."""
 
+from __future__ import annotations
+
 from pathlib import Path
 
-from framework.graph import EdgeSpec, EdgeCondition, Goal, SuccessCriterion, Constraint
-from framework.graph.edge import GraphSpec
+from framework.graph import (
+    EdgeSpec,
+    EdgeCondition,
+    Goal,
+    GraphSpec,
+    SuccessCriterion,
+    Constraint,
+)
 from framework.graph.executor import ExecutionResult
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/agent.py` around lines 1 - 19, Add "from
__future__ import annotations" as the very first import and consolidate the
GraphSpec import into the existing framework.graph import line by importing
GraphSpec alongside EdgeSpec, EdgeCondition, Goal, SuccessCriterion, and
Constraint; update the imports so GraphSpec comes from framework.graph (not
framework.graph.edge) to keep imports consistent (refer to GraphSpec, EdgeSpec,
EdgeCondition, Goal, SuccessCriterion, Constraint).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/templates/discord_digest/__main__.py`:
- Around line 13-20: Add type hints to the setup_logging function signature by
changing it to def setup_logging(verbose: bool = False, debug: bool = False) ->
None: so both parameters are annotated as bool and the function return type is
None; leave the internal implementation unchanged and ensure any callers still
pass booleans.

In `@examples/templates/discord_digest/agent.py`:
- Around line 217-225: Add explicit type hints to the async run method: annotate
parameters (e.g., context: Dict[str, Any], session_state:
Optional[YourSessionStateType] = None) and the return type (-> ExecutionResult).
Import needed typing symbols (Optional, Dict, Any) and replace
YourSessionStateType with the actual session state type used in this module;
keep the body using existing calls (start, trigger_and_wait, stop, and
ExecutionResult) unchanged.
- Around line 119-132: Add type hints to the DiscordDigestAgent.__init__
signature and its parameters/return: annotate the config parameter (e.g.,
RuntimeConfig or "RuntimeConfig") and annotate self return as None; update any
other parameters referenced/assigned in __init__ (goal, nodes, edges,
entry_node, entry_points, pause_nodes, terminal_nodes) with appropriate types or
forward-reference strings. If RuntimeConfig is available, import it at top;
otherwise enable from __future__ import annotations and use string annotations
to avoid circular imports. Ensure the method signature and any new imports
follow existing project style and lint rules.
- Around line 202-215: The trigger_and_wait method currently accepts a timeout
param but doesn't forward it to the runtime; update the method signature of
trigger_and_wait to include type hints (e.g., entry_point: str = "default",
input_data: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None,
session_state: Optional[Dict[str, Any]] = None) and pass timeout through to
self._agent_runtime.trigger_and_wait by adding timeout=timeout to that call (or
if you prefer to remove the parameter, delete timeout from the signature and all
references); refer to the trigger_and_wait method and the
self._agent_runtime.trigger_and_wait call when making the change.

In `@examples/templates/discord_digest/nodes/__init__.py`:
- Around line 57-58: The prompt instructions call load_data and save_data
without the required data_dir positional argument; update the prompt text to
call load_data("discord_digest_cursors", data_dir) and
save_data("discord_digest_cursors", updated_cursor_dict, data_dir) (or
equivalent variable name for the data directory) so the LLM-generated tool calls
match the actual function signatures load_data(filename, data_dir, ...) and
save_data(filename, data, data_dir); update both occurrences around the load at
"discord_digest_cursors" and the later save call so the tool won't fail due to
missing data_dir.

---

Nitpick comments:
In `@examples/templates/discord_digest/__main__.py`:
- Around line 23-27: Replace the hardcoded version string in the
click.version_option decorator with the centralized version constant; import
AgentMetadata (or the module exporting version) and use AgentMetadata.version in
the click.version_option call inside the cli function so the CLI version matches
the project's single source of truth (refer to the cli function and the
click.version_option usage and the AgentMetadata.version symbol).

In `@examples/templates/discord_digest/agent.py`:
- Around line 1-19: Add "from __future__ import annotations" as the very first
import and consolidate the GraphSpec import into the existing framework.graph
import line by importing GraphSpec alongside EdgeSpec, EdgeCondition, Goal,
SuccessCriterion, and Constraint; update the imports so GraphSpec comes from
framework.graph (not framework.graph.edge) to keep imports consistent (refer to
GraphSpec, EdgeSpec, EdgeCondition, Goal, SuccessCriterion, Constraint).

In `@examples/templates/discord_digest/config.py`:
- Around line 1-7: Add "from __future__ import annotations" as the first import
in this module to enable postponed evaluation of annotations and modern type
syntax; update the top of the file before any other imports (which currently
include dataclass and RuntimeConfig) so that dataclass usage and the
RuntimeConfig instantiation (default_config = RuntimeConfig()) benefit from
future annotations.

In `@examples/templates/discord_digest/nodes/__init__.py`:
- Around line 1-4: Add the future annotations import to the module by inserting
"from __future__ import annotations" at the top of the file before any other
imports or module-level code (the file containing the module docstring and the
import of NodeSpec from framework.graph). This ensures forward-compatible type
annotations in the module that defines the Discord Community Digest nodes
(referenced symbol: NodeSpec) and follows the project coding guidelines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3ac19822-5bea-4f5d-91b9-66756967d60a

📥 Commits

Reviewing files that changed from the base of the PR and between ae85d2b and 82b41fe.

📒 Files selected for processing (6)
  • examples/templates/discord_digest/__init__.py
  • examples/templates/discord_digest/__main__.py
  • examples/templates/discord_digest/agent.py
  • examples/templates/discord_digest/config.py
  • examples/templates/discord_digest/mcp_servers.json
  • examples/templates/discord_digest/nodes/__init__.py

Comment on lines +13 to +20
def setup_logging(verbose=False, debug=False):
if debug:
level, fmt = logging.DEBUG, "%(asctime)s %(name)s: %(message)s"
elif verbose:
level, fmt = logging.INFO, "%(message)s"
else:
level, fmt = logging.WARNING, "%(levelname)s: %(message)s"
logging.basicConfig(level=level, format=fmt, stream=sys.stderr)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add type hints to setup_logging function.

Per coding guidelines, all function signatures should have type hints.

Suggested fix
-def setup_logging(verbose=False, debug=False):
+def setup_logging(verbose: bool = False, debug: bool = False) -> None:
     if debug:
         level, fmt = logging.DEBUG, "%(asctime)s %(name)s: %(message)s"
     elif verbose:
         level, fmt = logging.INFO, "%(message)s"
     else:
         level, fmt = logging.WARNING, "%(levelname)s: %(message)s"
     logging.basicConfig(level=level, format=fmt, stream=sys.stderr)

As per coding guidelines: "Use type hints on all function signatures".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/__main__.py` around lines 13 - 20, Add type
hints to the setup_logging function signature by changing it to def
setup_logging(verbose: bool = False, debug: bool = False) -> None: so both
parameters are annotated as bool and the function return type is None; leave the
internal implementation unchanged and ensure any callers still pass booleans.

Comment on lines +119 to +132
class DiscordDigestAgent:
def __init__(self, config=None):
self.config = config or default_config
self.goal = goal
self.nodes = nodes
self.edges = edges
self.entry_node = entry_node
self.entry_points = entry_points
self.pause_nodes = pause_nodes
self.terminal_nodes = terminal_nodes
self._graph = None
self._agent_runtime = None
self._tool_registry = None
self._storage_path = None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add type hints to __init__ method.

Per coding guidelines, function signatures should have type hints.

Suggested fix
-    def __init__(self, config=None):
+    def __init__(self, config: RuntimeConfig | None = None) -> None:
         self.config = config or default_config

You'll need to import RuntimeConfig or use a string annotation with from __future__ import annotations.

As per coding guidelines: "Use type hints on all function signatures".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/agent.py` around lines 119 - 132, Add type
hints to the DiscordDigestAgent.__init__ signature and its parameters/return:
annotate the config parameter (e.g., RuntimeConfig or "RuntimeConfig") and
annotate self return as None; update any other parameters referenced/assigned in
__init__ (goal, nodes, edges, entry_node, entry_points, pause_nodes,
terminal_nodes) with appropriate types or forward-reference strings. If
RuntimeConfig is available, import it at top; otherwise enable from __future__
import annotations and use string annotations to avoid circular imports. Ensure
the method signature and any new imports follow existing project style and lint
rules.

Comment on lines +202 to +215
async def trigger_and_wait(
self,
entry_point="default",
input_data=None,
timeout=None,
session_state=None,
):
if self._agent_runtime is None:
raise RuntimeError("Agent not started. Call start() first.")
return await self._agent_runtime.trigger_and_wait(
entry_point_id=entry_point,
input_data=input_data or {},
session_state=session_state,
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if agent_runtime.trigger_and_wait accepts a timeout parameter
ast-grep --pattern $'async def trigger_and_wait($$$) -> $_:
    $$$'

Repository: aden-hive/hive

Length of output: 13939


🏁 Script executed:

cat -n examples/templates/discord_digest/agent.py | sed -n '200,220p'

Repository: aden-hive/hive

Length of output: 848


🏁 Script executed:

grep -n "trigger_and_wait" examples/templates/discord_digest/agent.py

Repository: aden-hive/hive

Length of output: 210


🏁 Script executed:

cat -n examples/templates/discord_digest/agent.py | sed -n '217,230p'

Repository: aden-hive/hive

Length of output: 625


Forward timeout parameter to underlying trigger_and_wait() call or remove it.

The timeout parameter is defined in the method signature but not passed to self._agent_runtime.trigger_and_wait(), which accepts and uses it. Either remove the parameter or forward it to maintain consistency with other agent templates.

Additionally, add type hints to the method signature to match the codebase conventions:

Suggested fix
     async def trigger_and_wait(
         self,
-        entry_point="default",
-        input_data=None,
-        timeout=None,
-        session_state=None,
-    ):
+        entry_point: str = "default",
+        input_data: dict | None = None,
+        timeout: float | None = None,
+        session_state: dict | None = None,
+    ) -> ExecutionResult:
         if self._agent_runtime is None:
             raise RuntimeError("Agent not started. Call start() first.")
         return await self._agent_runtime.trigger_and_wait(
             entry_point_id=entry_point,
             input_data=input_data or {},
             session_state=session_state,
+            timeout=timeout,
         )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async def trigger_and_wait(
self,
entry_point="default",
input_data=None,
timeout=None,
session_state=None,
):
if self._agent_runtime is None:
raise RuntimeError("Agent not started. Call start() first.")
return await self._agent_runtime.trigger_and_wait(
entry_point_id=entry_point,
input_data=input_data or {},
session_state=session_state,
)
async def trigger_and_wait(
self,
entry_point: str = "default",
input_data: dict | None = None,
timeout: float | None = None,
session_state: dict | None = None,
) -> ExecutionResult:
if self._agent_runtime is None:
raise RuntimeError("Agent not started. Call start() first.")
return await self._agent_runtime.trigger_and_wait(
entry_point_id=entry_point,
input_data=input_data or {},
session_state=session_state,
timeout=timeout,
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/agent.py` around lines 202 - 215, The
trigger_and_wait method currently accepts a timeout param but doesn't forward it
to the runtime; update the method signature of trigger_and_wait to include type
hints (e.g., entry_point: str = "default", input_data: Optional[Dict[str, Any]]
= None, timeout: Optional[float] = None, session_state: Optional[Dict[str, Any]]
= None) and pass timeout through to self._agent_runtime.trigger_and_wait by
adding timeout=timeout to that call (or if you prefer to remove the parameter,
delete timeout from the signature and all references); refer to the
trigger_and_wait method and the self._agent_runtime.trigger_and_wait call when
making the change.

Comment on lines +217 to +225
async def run(self, context, session_state=None):
await self.start()
try:
result = await self.trigger_and_wait(
"default", context, session_state=session_state
)
return result or ExecutionResult(success=False, error="Execution timeout")
finally:
await self.stop()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add type hints to run method.

Suggested fix
-    async def run(self, context, session_state=None):
+    async def run(
+        self, context: dict, session_state: dict | None = None
+    ) -> ExecutionResult:
         await self.start()

As per coding guidelines: "Use type hints on all function signatures".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async def run(self, context, session_state=None):
await self.start()
try:
result = await self.trigger_and_wait(
"default", context, session_state=session_state
)
return result or ExecutionResult(success=False, error="Execution timeout")
finally:
await self.stop()
async def run(
self, context: dict, session_state: dict | None = None
) -> ExecutionResult:
await self.start()
try:
result = await self.trigger_and_wait(
"default", context, session_state=session_state
)
return result or ExecutionResult(success=False, error="Execution timeout")
finally:
await self.stop()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/agent.py` around lines 217 - 225, Add
explicit type hints to the async run method: annotate parameters (e.g., context:
Dict[str, Any], session_state: Optional[YourSessionStateType] = None) and the
return type (-> ExecutionResult). Import needed typing symbols (Optional, Dict,
Any) and replace YourSessionStateType with the actual session state type used in
this module; keep the body using existing calls (start, trigger_and_wait, stop,
and ExecutionResult) unchanged.

Comment on lines +57 to +58
1. Load the dedup cursor by calling load_data("discord_digest_cursors").
If the file doesn't exist, start with an empty dict {{}}.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify load_data and save_data signatures
ast-grep --pattern $'def load_data($$$) -> $_:
    $$$'

ast-grep --pattern $'def save_data($$$) -> $_:
    $$$'

Repository: aden-hive/hive

Length of output: 17094


🏁 Script executed:

# Check the file size first
wc -l examples/templates/discord_digest/nodes/__init__.py

Repository: aden-hive/hive

Length of output: 113


🏁 Script executed:

# Read the file around lines 57-58 and 79-80
sed -n '50,85p' examples/templates/discord_digest/nodes/__init__.py

Repository: aden-hive/hive

Length of output: 1475


Update the prompt instructions to include data_dir parameter in function calls.

The prompt at lines 57-58 and 79-80 instructs the LLM to call:

  • load_data("discord_digest_cursors") — missing data_dir argument
  • save_data("discord_digest_cursors", updated_cursor_dict) — missing data_dir argument

The actual function signatures require data_dir as a mandatory positional parameter:

  • load_data(filename: str, data_dir: str, offset_bytes: int = 0, limit_bytes: int = 10000)
  • save_data(filename: str, data: str, data_dir: str)

LLM tool calls will fail due to missing arguments.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/templates/discord_digest/nodes/__init__.py` around lines 57 - 58,
The prompt instructions call load_data and save_data without the required
data_dir positional argument; update the prompt text to call
load_data("discord_digest_cursors", data_dir) and
save_data("discord_digest_cursors", updated_cursor_dict, data_dir) (or
equivalent variable name for the data directory) so the LLM-generated tool calls
match the actual function signatures load_data(filename, data_dir, ...) and
save_data(filename, data, data_dir); update both occurrences around the load at
"discord_digest_cursors" and the later save call so the tool won't fail due to
missing data_dir.

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.

[Feature]: Discord Community Digest Sample Agent Template

1 participant