Add multi-agent example (research + summary workflow using Bindu)#457
Add multi-agent example (research + summary workflow using Bindu)#457ManoharBM29 wants to merge 2 commits intoGetBindu:mainfrom
Conversation
📝 WalkthroughWalkthroughTwo new CrewAI-style agent examples are introduced for the Bindu framework. The multi-agent example demonstrates a sequential pipeline with a research agent and summary agent, complete with documentation and implementation. A simpler single-agent example provides a minimal starting point. Both integrate with Bindu through configuration and handler functions. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
examples/crewai_multi_agent/main.py (1)
9-17: Same unsafe indexing as the simple example.
messages[-1]["content"]will raise on empty or malformed input. Considermessages[-1].get("content", "") if messages else ""for a friendlier failure mode in an example meant for beginners.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/crewai_multi_agent/main.py` around lines 9 - 17, The handler function currently indexes messages unsafely with messages[-1]["content"]; change it to safely handle empty or malformed input by first checking if messages is truthy and then using .get("content", "") on the last message (e.g., compute user_input = messages[-1].get("content", "") if messages else ""), so research_agent and summary_agent always receive a string rather than raising an exception.examples/crewai_simple_agent/main.py (1)
4-10: Guard against missing/malformed messages.
messages[-1]["content"]will raiseIndexErroron empty lists andKeyError/TypeErrorif the last message lacks acontentkey or isn't a dict. A beginner-friendly example should fail gracefully.🛡️ Proposed fix
def handler(messages): - user_input = messages[-1]["content"] - + user_input = (messages[-1].get("content", "") if messages else "") + return [{ "role": "assistant", "content": f"👋 Hello! You said: {user_input}\n\nThis is a simple CrewAI-style agent running on Bindu." }]🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/crewai_simple_agent/main.py` around lines 4 - 10, The handler currently does messages[-1]["content"] which can raise IndexError/KeyError/TypeError; update the handler to validate that messages is a non-empty list, that the last element is a dict with a "content" key (and that its value is a string), and use a safe fallback (e.g., a default prompt like "<no input provided>") when validation fails; then build and return the assistant response using that safe user_input. Reference the handler function and the messages[-1]["content"] access when making the checks and fallback handling.
🤖 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/crewai_multi_agent/main.py`:
- Line 20: Replace the placeholder value for the "author" field (the string
"your_email@example.com") in the examples' metadata so it doesn't ship as-is:
update the "author" value to a real maintainer email or, if you prefer not to
publish a real address, replace it with a clear inline comment instructing users
to substitute their own email before running. Apply this change to the "author"
entry in both the examples/crewai_multi_agent main module and the
examples/crewai_simple_agent main module so the key "author" no longer contains
the placeholder string.
- Around line 6-7: summary_agent currently ignores its parameter and returns a
constant string (the f-string is redundant); update the function (summary_agent)
to incorporate the research_text parameter into the returned summary (e.g.,
produce a short summary or include the original research_text/context in the
output) and remove the unnecessary f prefix if you don't interpolate — ensure
the returned string references research_text so data flows from the research
agent into the summary agent.
In `@examples/crewai_multi_agent/README`:
- Around line 76-80: The README example output is out of sync with the actual
text returned by research_agent() in main.py; update the README block to match
the handler's real response (or change research_agent() to produce the README
text). Specifically, locate the research_agent() handler in main.py and either
adjust its returned string to "📊 Research Data on 'Explain AI agents': AI
agents are systems that can perform tasks autonomously using LLMs." and matching
summary text, or edit the README example to exactly match the current handler
output: "📊 Research Data:\n'Explain AI agents' involves autonomous systems that
use reasoning, memory, and tools to complete tasks." and the corresponding
summary line so copy-pasted examples produce the same result.
- Around line 30-104: The README has an unclosed ```bash fence causing the rest
to render as a single code block; close the initial ```bash fence and add
appropriate fenced blocks and heading markers: close the ```bash after the two
commands shown, add "## 🧪 Testing (Postman)" and "### 1️⃣ Send Request"/"###
2️⃣ Get Result" headings, wrap each JSON payload in ```json fences, wrap the
example output in a fenced block, and add "##" headings for "📌 Example Output",
"💡 Key Concepts Demonstrated", "🎯 Purpose", and "📦 Scope"; also rename the
file from README to README.md so markdown renders correctly.
In `@examples/crewai_simple_agent/main.py`:
- Line 14: The manifest/example contains a placeholder author email under the
"author" field ("your_email@example.com"); replace this with a real
project-owned or maintainer email (consistent with other examples, e.g., a
bindu.dev or team address) or add an inline comment next to the "author" field
telling users to swap in their own email before running so the required agent
identity is not left as a placeholder.
---
Nitpick comments:
In `@examples/crewai_multi_agent/main.py`:
- Around line 9-17: The handler function currently indexes messages unsafely
with messages[-1]["content"]; change it to safely handle empty or malformed
input by first checking if messages is truthy and then using .get("content", "")
on the last message (e.g., compute user_input = messages[-1].get("content", "")
if messages else ""), so research_agent and summary_agent always receive a
string rather than raising an exception.
In `@examples/crewai_simple_agent/main.py`:
- Around line 4-10: The handler currently does messages[-1]["content"] which can
raise IndexError/KeyError/TypeError; update the handler to validate that
messages is a non-empty list, that the last element is a dict with a "content"
key (and that its value is a string), and use a safe fallback (e.g., a default
prompt like "<no input provided>") when validation fails; then build and return
the assistant response using that safe user_input. Reference the handler
function and the messages[-1]["content"] access when making the checks and
fallback handling.
🪄 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: da8c6b8c-6e5a-4c5f-a49a-ec0d4d357b21
📒 Files selected for processing (3)
examples/crewai_multi_agent/READMEexamples/crewai_multi_agent/main.pyexamples/crewai_simple_agent/main.py
| def summary_agent(research_text): | ||
| return f"📝 Summary:\nThis topic explains how AI agents work step-by-step to solve problems efficiently." |
There was a problem hiding this comment.
summary_agent ignores its input and has a useless f-string.
research_text is never referenced in the body, and the returned string contains no interpolation, so the f prefix is redundant (flagged by Ruff F541). This defeats the purpose of a "summary" agent — regardless of what the research agent produced (or what the user asked), the summary is a fixed sentence. At minimum, incorporate research_text (or the original query) into the output so the pipeline demonstrates data flow between agents.
♻️ Proposed fix
-def summary_agent(research_text):
- return f"📝 Summary:\nThis topic explains how AI agents work step-by-step to solve problems efficiently."
+def summary_agent(research_text):
+ # Trivially summarize by taking the first sentence of the research output.
+ first_sentence = research_text.split(".")[0].strip()
+ return f"📝 Summary:\n{first_sentence}."📝 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.
| def summary_agent(research_text): | |
| return f"📝 Summary:\nThis topic explains how AI agents work step-by-step to solve problems efficiently." | |
| def summary_agent(research_text): | |
| # Trivially summarize by taking the first sentence of the research output. | |
| first_sentence = research_text.split(".")[0].strip() | |
| return f"📝 Summary:\n{first_sentence}." |
🧰 Tools
🪛 Ruff (0.15.10)
[error] 7-7: f-string without any placeholders
Remove extraneous f prefix
(F541)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@examples/crewai_multi_agent/main.py` around lines 6 - 7, summary_agent
currently ignores its parameter and returns a constant string (the f-string is
redundant); update the function (summary_agent) to incorporate the research_text
parameter into the returned summary (e.g., produce a short summary or include
the original research_text/context in the output) and remove the unnecessary f
prefix if you don't interpolate — ensure the returned string references
research_text so data flows from the research agent into the summary agent.
| }] | ||
|
|
||
| config = { | ||
| "author": "your_email@example.com", |
There was a problem hiding this comment.
Replace placeholder author email.
"your_email@example.com" ships as-is. Either use a real maintainer address or add a comment telling users to substitute theirs before running. Same note applies to examples/crewai_simple_agent/main.py.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@examples/crewai_multi_agent/main.py` at line 20, Replace the placeholder
value for the "author" field (the string "your_email@example.com") in the
examples' metadata so it doesn't ship as-is: update the "author" value to a real
maintainer email or, if you prefer not to publish a real address, replace it
with a clear inline comment instructing users to substitute their own email
before running. Apply this change to the "author" entry in both the
examples/crewai_multi_agent main module and the examples/crewai_simple_agent
main module so the key "author" no longer contains the placeholder string.
| ```bash | ||
| cd examples/crewai_multi_agent | ||
| python main.py | ||
| 🧪 Testing (Postman) | ||
|
|
||
| 1️⃣ Send Request | ||
|
|
||
| POST → http://localhost:3773/ | ||
|
|
||
| { | ||
| "jsonrpc": "2.0", | ||
| "method": "message/send", | ||
| "params": { | ||
| "message": { | ||
| "role": "user", | ||
| "parts": [ | ||
| { | ||
| "kind": "text", | ||
| "text": "Explain AI agents" | ||
| } | ||
| ], | ||
| "kind": "message", | ||
| "messageId": "550e8400-e29b-41d4-a716-446655440100", | ||
| "contextId": "550e8400-e29b-41d4-a716-446655440101", | ||
| "taskId": "550e8400-e29b-41d4-a716-446655440102" | ||
| }, | ||
| "configuration": { | ||
| "acceptedOutputModes": ["application/json"] | ||
| } | ||
| }, | ||
| "id": "550e8400-e29b-41d4-a716-446655440199" | ||
| } | ||
|
|
||
|
|
||
| 2️⃣ Get Result | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "method": "tasks/get", | ||
| "params": { | ||
| "taskId": "550e8400-e29b-41d4-a716-446655440102" | ||
| }, | ||
| "id": "550e8400-e29b-41d4-a716-446655441299" | ||
| } | ||
|
|
||
|
|
||
| 📌 Example Output | ||
| 📊 Research Data on 'Explain AI agents': | ||
| AI agents are systems that can perform tasks autonomously using LLMs. | ||
|
|
||
| 📝 Summary: | ||
| AI agents are autonomous systems that use models to complete tasks efficiently. | ||
|
|
||
|
|
||
| 💡 Key Concepts Demonstrated | ||
| Multi-agent collaboration | ||
| Sequential task execution | ||
| Bindu async workflow: | ||
| message/send → task creation | ||
| tasks/get → result retrieval | ||
| Agent orchestration using bindufy() | ||
|
|
||
|
|
||
| 🎯 Purpose | ||
|
|
||
| This example helps developers: | ||
|
|
||
| Understand how to build multi-agent systems | ||
| Learn Bindu’s request-response lifecycle | ||
| Experiment without external API dependencies | ||
|
|
||
|
|
||
| 📦 Scope | ||
| No external APIs required | ||
| Beginner to intermediate friendly | ||
| Focused on core agent orchestration No newline at end of file |
There was a problem hiding this comment.
Markdown fencing is broken — most of the README renders as one giant code block.
The ```bash fence opened on Line 30 is never closed. As a result, everything from Line 33 onward ("🧪 Testing (Postman)", the JSON request/response bodies, "Key Concepts", "Purpose", "Scope") renders as bash code rather than formatted prose. Additionally, the two JSON payloads and the example output section have no fences of their own, and headings like "🧪 Testing (Postman)", "📌 Example Output", "💡 Key Concepts Demonstrated", "🎯 Purpose", "📦 Scope" are missing ##/`###` prefixes so they don't render as headings.
📝 Proposed structural fix
```bash
cd examples/crewai_multi_agent
python main.py
-🧪 Testing (Postman)
+```
+
+---
-1️⃣ Send Request
+## 🧪 Testing (Postman)
-POST → http://localhost:3773/
+### 1️⃣ Send Request
+`POST → http://localhost:3773/`
+
+```json
{
"jsonrpc": "2.0",
"method": "message/send",
...
"id": "550e8400-e29b-41d4-a716-446655440199"
}
+```
-
-2️⃣ Get Result
+### 2️⃣ Get Result
+
+```json
{
"jsonrpc": "2.0",
"method": "tasks/get",
...
"id": "550e8400-e29b-41d4-a716-446655441299"
}
+```
-
-📌 Example Output
+## 📌 Example Output
+
+```
📊 Research Data on 'Explain AI agents':
AI agents are systems that can perform tasks autonomously using LLMs.
📝 Summary:
AI agents are autonomous systems that use models to complete tasks efficiently.
+```
-
-💡 Key Concepts Demonstrated
+## 💡 Key Concepts Demonstrated
+
+- Multi-agent collaboration
+- Sequential task execution
+- Bindu async workflow: `message/send` → task creation, `tasks/get` → result retrieval
+- Agent orchestration using `bindufy()`Also worth fixing: the file is named README — rename to README.md (the PR description mentions README.md) so GitHub and IDEs render it as Markdown.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@examples/crewai_multi_agent/README` around lines 30 - 104, The README has an
unclosed ```bash fence causing the rest to render as a single code block; close
the initial ```bash fence and add appropriate fenced blocks and heading markers:
close the ```bash after the two commands shown, add "## 🧪 Testing (Postman)"
and "### 1️⃣ Send Request"/"### 2️⃣ Get Result" headings, wrap each JSON payload
in ```json fences, wrap the example output in a fenced block, and add "##"
headings for "📌 Example Output", "💡 Key Concepts Demonstrated", "🎯 Purpose",
and "📦 Scope"; also rename the file from README to README.md so markdown
renders correctly.
| 📊 Research Data on 'Explain AI agents': | ||
| AI agents are systems that can perform tasks autonomously using LLMs. | ||
|
|
||
| 📝 Summary: | ||
| AI agents are autonomous systems that use models to complete tasks efficiently. |
There was a problem hiding this comment.
Example output doesn't match what main.py actually returns.
The README shows 📊 Research Data on 'Explain AI agents': and a sentence about LLMs, but research_agent() in main.py produces 📊 Research Data:\n'Explain AI agents' involves autonomous systems that use reasoning, memory, and tools to complete tasks. Similarly the summary text differs. Users copy-pasting the request will see different output than documented — please sync the README with the actual handler output (or vice versa).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@examples/crewai_multi_agent/README` around lines 76 - 80, The README example
output is out of sync with the actual text returned by research_agent() in
main.py; update the README block to match the handler's real response (or change
research_agent() to produce the README text). Specifically, locate the
research_agent() handler in main.py and either adjust its returned string to "📊
Research Data on 'Explain AI agents': AI agents are systems that can perform
tasks autonomously using LLMs." and matching summary text, or edit the README
example to exactly match the current handler output: "📊 Research
Data:\n'Explain AI agents' involves autonomous systems that use reasoning,
memory, and tools to complete tasks." and the corresponding summary line so
copy-pasted examples produce the same result.
|
|
||
|
|
||
| config = { | ||
| "author": "your_email@example.com", |
There was a problem hiding this comment.
Placeholder author email shipped as-is.
"your_email@example.com" is a placeholder. Since author is a required field used for agent identity, either use a real project-owned address (e.g., a bindu.dev / maintainer email consistent with other examples) or add an inline comment telling users to replace it before running.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@examples/crewai_simple_agent/main.py` at line 14, The manifest/example
contains a placeholder author email under the "author" field
("your_email@example.com"); replace this with a real project-owned or maintainer
email (consistent with other examples, e.g., a bindu.dev or team address) or add
an inline comment next to the "author" field telling users to swap in their own
email before running so the required agent identity is not left as a
placeholder.
🚀 Added Multi-Agent Example using Bindu
📌 Summary
This PR introduces a multi-agent example demonstrating how multiple agents can collaborate sequentially using Bindu.
🧠 What’s included
💡 Why this matters
This example demonstrates agent orchestration using Bindu’s async architecture. It helps developers understand how to build multi-step agent workflows without relying on external APIs.
🧪 Testing
localhost:3773)message/send→ task submissiontasks/get→ result retrieval📂 Files added
examples/crewai_multi_agent/main.pyexamples/crewai_multi_agent/README.md🎯 Scope
Summary by CodeRabbit
Release Notes
New Features
Documentation