Add beginner-friendly simple agent example (no API dependency)#456
Add beginner-friendly simple agent example (no API dependency)#456ManoharBM29 wants to merge 1 commit intoGetBindu:mainfrom
Conversation
📝 WalkthroughWalkthroughA new example agent file is added to demonstrate a simple CrewAI-style agent implementation using Bindu. The handler extracts the latest user message, returns an assistant response with a greeting and echo, and is registered via configuration metadata and deployment settings. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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: 2
🧹 Nitpick comments (2)
examples/crewai_simple_agent/main.py (2)
14-14: Placeholder author email.
your_email@example.comis a template placeholder. Sincebindufy()documentsauthoras a required field and this file is executed directly viabindufy(config, handler)at import time (Line 25), consider either adding a brief comment instructing users to replace it, or using a clearly fake-but-valid-looking value with an inline# TODO: replace with your emailmarker so copy-paste users don't ship it unchanged.- "author": "your_email@example.com", + "author": "your_email@example.com", # TODO: replace with your email 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, Replace the placeholder author value "your_email@example.com" in the config passed to bindufy(config, handler) with a clearly fake-but-valid-looking email and a TODO note so users know to change it; e.g., set the author field to something like "dev@example.invalid" or "your.name@replace.me" and append an inline comment "# TODO: replace with your email" next to the author key in the example so copy-paste users won’t accidentally ship the placeholder when the module is executed at import time.
25-25: Guard the top-levelbindufy()call withif __name__ == "__main__":.Calling
bindufy(config, handler)at module import time means anyimportof this file (e.g., from tests or tooling) will attempt to start the server. Wrapping it in a main-guard is the standard Python idiom and prevents surprises.♻️ Proposed refactor
-bindufy(config, handler) +if __name__ == "__main__": + bindufy(config, handler)🤖 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 25, The top-level call to bindufy(config, handler) is executed at import time; wrap that call in a module guard by adding an if __name__ == "__main__": block and moving bindufy(config, handler) inside it so imports won't start the server; update the example's main module to only invoke bindufy when run as the main program, referencing the existing bindufy, config and handler symbols.
🤖 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_simple_agent/main.py`:
- Around line 15-16: The example's metadata and strings use the misleading
"crewai_simple_agent" name and CrewAI branding (e.g., the "crewai_simple_agent"
value and the description string "Beginner-friendly simple agent using Bindu (no
API key required)"); update these to a neutral name such as "simple_agent" or
"hello_agent" and change any response text or description that mentions "CrewAI"
to match the new name, or alternatively wire in a minimal CrewAI
import/initialization if CrewAI branding is intended (change the
"crewai_simple_agent" string and any response/description constants and ensure
any agent-creation code uses the CrewAI client if choosing the integration
route).
- Around line 4-10: The handler currently assumes messages[-1]["content"] exists
and will crash on empty or malformed input; modify the handler to defensively
access the last message by first checking that messages is a non-empty list,
then retrieve last_message = messages[-1] and use last_message.get("content",
"") (or validate it's a dict with a "content" key) and fall back to a safe
default string if missing, and return the same assistant response but
referencing the safe user_input variable so the function never raises
IndexError/KeyError.
---
Nitpick comments:
In `@examples/crewai_simple_agent/main.py`:
- Line 14: Replace the placeholder author value "your_email@example.com" in the
config passed to bindufy(config, handler) with a clearly fake-but-valid-looking
email and a TODO note so users know to change it; e.g., set the author field to
something like "dev@example.invalid" or "your.name@replace.me" and append an
inline comment "# TODO: replace with your email" next to the author key in the
example so copy-paste users won’t accidentally ship the placeholder when the
module is executed at import time.
- Line 25: The top-level call to bindufy(config, handler) is executed at import
time; wrap that call in a module guard by adding an if __name__ == "__main__":
block and moving bindufy(config, handler) inside it so imports won't start the
server; update the example's main module to only invoke bindufy when run as the
main program, referencing the existing bindufy, config and handler symbols.
🪄 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: 39b52260-4874-4a66-89df-12f938ce832c
📒 Files selected for processing (1)
examples/crewai_simple_agent/main.py
| def handler(messages): | ||
| user_input = messages[-1]["content"] | ||
|
|
||
| return [{ | ||
| "role": "assistant", | ||
| "content": f"👋 Hello! You said: {user_input}\n\nThis is a simple CrewAI-style agent running on Bindu." | ||
| }] |
There was a problem hiding this comment.
Handler will crash on empty or malformed messages.
messages[-1]["content"] raises IndexError if the list is empty and KeyError if the last entry lacks a content key. Even for a beginner example, a graceful fallback is worth modeling since users will copy this pattern.
🛡️ Proposed defensive 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."
}]📝 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 handler(messages): | |
| user_input = messages[-1]["content"] | |
| return [{ | |
| "role": "assistant", | |
| "content": f"👋 Hello! You said: {user_input}\n\nThis is a simple CrewAI-style agent running on Bindu." | |
| }] | |
| def handler(messages): | |
| 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 assumes messages[-1]["content"] exists and will crash on empty or
malformed input; modify the handler to defensively access the last message by
first checking that messages is a non-empty list, then retrieve last_message =
messages[-1] and use last_message.get("content", "") (or validate it's a dict
with a "content" key) and fall back to a safe default string if missing, and
return the same assistant response but referencing the safe user_input variable
so the function never raises IndexError/KeyError.
| "name": "crewai_simple_agent", | ||
| "description": "Beginner-friendly simple agent using Bindu (no API key required)", |
There was a problem hiding this comment.
Misleading "CrewAI" branding.
The directory, agent name, and response text all reference "CrewAI", but the example doesn't import or use CrewAI at all — it's a plain Python handler. This will confuse beginners who come looking for a CrewAI integration example. Consider renaming to something like simple_agent / hello_agent, or actually wiring in a minimal CrewAI agent if the CrewAI branding is intended.
🤖 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 15 - 16, The example's
metadata and strings use the misleading "crewai_simple_agent" name and CrewAI
branding (e.g., the "crewai_simple_agent" value and the description string
"Beginner-friendly simple agent using Bindu (no API key required)"); update
these to a neutral name such as "simple_agent" or "hello_agent" and change any
response text or description that mentions "CrewAI" to match the new name, or
alternatively wire in a minimal CrewAI import/initialization if CrewAI branding
is intended (change the "crewai_simple_agent" string and any
response/description constants and ensure any agent-creation code uses the
CrewAI client if choosing the integration route).
🚀 Added Simple Beginner-Friendly Agent Example
Summary
This PR adds a minimal agent example using Bindu that does not require any external API keys.
What changed
examples/crewai_simple_agent/bindufy()Why it matters
This helps new developers quickly understand how to use Bindu without needing API setup or external services.
Testing
Scope
Summary by CodeRabbit