Skip to content

Add Smart Research Assistant example using Bindu + Agno with web rese…#327

Open
MayurUghade03 wants to merge 1 commit intoGetBindu:mainfrom
MayurUghade03:add/smart-research-assistant
Open

Add Smart Research Assistant example using Bindu + Agno with web rese…#327
MayurUghade03 wants to merge 1 commit intoGetBindu:mainfrom
MayurUghade03:add/smart-research-assistant

Conversation

@MayurUghade03
Copy link

Add Smart Research Assistant - Production-Ready Bindu Agent Example

Overview

This PR adds a complete, production-ready example agent to the Bindu repository that demonstrates how to build intelligent research capabilities using the Bindu framework.

What This Example Shows

  • Official Bindu Patterns: Uses bindu.penguin.bindufy and proper configuration structure
  • Typed Handler: Implements the official Bindu handler contract: handler(messages: list) -> dict[str, Any]
  • Agno Integration: Shows how to compose agents with Agno's Agent class, tools, and model selection
  • Web Search: Demonstrates using DuckDuckGo tool (requires no API key)
  • LLM Flexibility: OpenAI-first with OpenRouter fallback for model choice
  • Structured Output: Returns responses with summary, key points, sources, and timestamp
  • Security Best Practices: Environment-based configuration, .gitignore coverage, no hardcoded secrets
  • Modern Tooling: Includes pyproject.toml for UV workflow and requirements.txt for pip

Project Contents

  • agent.py (348 lines)

    • CONFIG dict matching official Bindu format
    • Typed handler function with error handling
    • Agno Agent factory for research capability
    • Demo mode for local testing (python agent.py --demo)
  • README.md

    • Quick start guide (UV + venv setup)
    • Usage examples (demo, HTTP API, Python calls)
    • Handler contract documentation
    • Security and configuration notes
  • requirements.txt & pyproject.toml

    • Clean dependency list
    • Python 3.12+ requirement
    • Tool configurations (black, ruff)
  • .gitignore

    • Covers .env, venv, IDE files, credentials patterns
    • Prevents accidental secret commits
  • Supporting files

    • architecture.md - System design explanation
    • demo_working.py - Demo with mock output (no API needed)
    • test_components.py - Unit tests for imports and structure
    • QUICK_REFERENCE.md - Quick setup reference

Design Decisions

  1. Bindu Integration: Uses official bindufy(config=CONFIG, handler_func=handler) registration pattern, making agent discoverable and deployable on Bindu infrastructure.

  2. Agno for Agent Composition: Leverages Agno's clean API for tool integration, LLM selection, and agent orchestration—avoiding low-level OpenAI client calls.

  3. DuckDuckGo for Search: No API key required, fast, reliable—suitable for example agent without external credential requirements.

  4. Structured Response: Guarantees consistent output format so Bindu infrastructure and consuming agents can rely on known schema.

  5. Error Resilience: Handler catches exceptions gracefully, logs appropriately, and returns error status—prevents crashes in production Bindu deployments.

Alignment with Official Patterns

✅ Uses from bindu.penguin.bindufy import bindufy (official import)
✅ CONFIG dict with author, name, description, deployment, skills
✅ Typed handler: def handler(messages: list[dict[str, str]]) -> dict[str, Any]
✅ Environment variables: OPENAI_API_KEY, OPENROUTER_API_KEY
✅ Structured response: {"status", "response": {...}, "error"}
✅ Security: No hardcoded keys, .gitignore coverage
✅ Modern tooling: pyproject.toml, requirements.txt

Testing

  • Local Demo: python agent.py --demo (no API key required for demo structure validation)
  • Component Test: python test_components.py (verifies imports and agent creation)
  • Integration: Handler can be called directly from Python or via Bindu HTTP API

Known Limitations

  • Requires OpenAI API key (or alternative via OpenRouter) for actual research calls
  • If OpenAI account lacks quota/billing, API calls will fail with 429 insufficient_quota (account-level issue, not code issue)
  • Search relies on DuckDuckGo availability in user's region

Intended Use

  • Learning Resource: Shows how to implement a real capability agent using Bindu + Agno
  • Project Template: Developers can fork/extend this example to build their own agents
  • Community Example: Demonstrates best practices for configuration, error handling, security

Checklist

  • Follows official Bindu patterns (bindufy import, CONFIG structure, handler signature)
  • Uses typed Python (3.12+)
  • Includes comprehensive documentation
  • No hardcoded credentials
  • Tests included (demo mode + component tests)
  • .gitignore covers sensitive artifacts
  • pyproject.toml + requirements.txt for dependency management
  • Clear commit message

Related Issues

Closes: (Reference any open issues if applicable, e.g., "Closes #123")


Reviewer Notes: This example is production-ready and demonstrates alignment with official Bindu documentation. It serves as a reference implementation for community members building their own agents.

Copilot AI review requested due to automatic review settings March 4, 2026 16:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new examples/smart_research_agent/ “Smart Research Assistant” example intended to demonstrate building a web-research agent using Bindu + Agno, including local demo tooling and accompanying documentation.

Changes:

  • Added a Bindu/Agno-based research agent implementation (agent.py) with structured response parsing and demo mode.
  • Added extensive documentation and reference guides (README, architecture, quick reference, requirements guide).
  • Added example-specific dependency/config files (requirements.txt, pyproject.toml, .gitignore) plus a component verification script and mock demo.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
examples/smart_research_agent/agent.py Implements the agent handler + Agno agent factory and attempts Bindu registration / demo mode.
examples/smart_research_agent/test_components.py Adds a component-check script (imports, DDG search check, response parsing check).
examples/smart_research_agent/README.md Provides setup and usage instructions for running and calling the agent.
examples/smart_research_agent/architecture.md Documents intended architecture and data flow.
examples/smart_research_agent/QUICK_REFERENCE.md Quickstart and common commands/env vars reference.
examples/smart_research_agent/REQUIREMENTS.md Detailed setup/troubleshooting guide.
examples/smart_research_agent/demo_working.py Mock/demo script producing sample output without real LLM calls.
examples/smart_research_agent/requirements.txt Pip requirements for the example.
examples/smart_research_agent/pyproject.toml UV/packaging + formatter/linter config for the example.
examples/smart_research_agent/.gitignore Example-local ignore rules for env files, venv, logs, etc.
Comments suppressed due to low confidence (4)

examples/smart_research_agent/agent.py:76

  • SEARCH_MAX_RESULTS and SEARCH_TIMEOUT are read from the environment but never used. This makes the documented configuration knobs ineffective and risks confusing users. Either wire these values into the DuckDuckGo tool configuration (if supported) or remove the env vars and related README mentions.
# Search configuration
SEARCH_MAX_RESULTS = int(os.getenv("SEARCH_MAX_RESULTS", "10"))
SEARCH_TIMEOUT = int(os.getenv("SEARCH_TIMEOUT", "30"))

examples/smart_research_agent/test_components.py:71

  • The instructions here refer to LLM_API_KEY, but the agent code reads OPENAI_API_KEY / OPENROUTER_API_KEY. This will mislead users into setting an env var that the agent never uses. Align the setup instructions with the actual environment variables used by agent.py.
print("\nTo run with LLM integration:")
print("  1. Set environment variable: $env:LLM_API_KEY='your-key'")
print("  2. Run: python agent.py --demo")

examples/smart_research_agent/architecture.md:23

  • This architecture doc describes a POST /handler HTTP endpoint and shows @bindufy(...) as a decorator. In this repo, Bindu serves the A2A JSON-RPC endpoint on POST / (and bindufy is used as a function call as in other examples), so the documented request path/registration mechanism doesn’t match how the agent will actually be invoked. Please update the diagram and entrypoint description to reflect the JSON-RPC flow used by Bindu.
                    POST /handler
                             │
                    ┌────────▼────────┐
                    │   handler()     │
                    │   (decorated)   │
                    └────────┬────────┘

examples/smart_research_agent/README.md:93

  • The command bindu server --agent agent.py doesn’t appear to exist in this repo (there’s no CLI entrypoint defined), and other examples start agents by running the Python file that calls bindufy(...). Consider updating this to python agent.py / uv run python agent.py (and ensure bindufy is only invoked under __main__ if you also want a --demo mode).
### Start with Bindu

```bash
bindu server --agent agent.py
</details>

Comment on lines +78 to +90
```bash
# Create .env file
cat > .env << EOF
# OpenAI API Configuration
LLM_PROVIDER=openai
LLM_MODEL=gpt-4-turbo
LLM_API_KEY=your-actual-api-key-here
LLM_BASE_URL=

# Search Configuration (optional)
SEARCH_MAX_RESULTS=10
SEARCH_TIMEOUT=30
EOF
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The .env example and environment variable section use LLM_API_KEY / LLM_PROVIDER / LLM_MODEL, but agent.py expects OPENAI_API_KEY / OPENROUTER_API_KEY and LLM_MODEL. This mismatch will cause setup failures for anyone following this guide. Please align the variable names with the implementation (or update the code to support the documented names).

Copilot uses AI. Check for mistakes.

# Register agent with Bindu framework
# This makes the agent discoverable and deployable
bindufy(config=CONFIG, handler_func=handler)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

bindufy is called with handler_func=..., but the actual signature is bindufy(config, handler, ...) (keyword is handler). As written this will raise TypeError: bindufy() got an unexpected keyword argument 'handler_func' at import time, preventing the agent from starting. Update the call to pass the handler using the correct parameter name (or as the 2nd positional arg).

Suggested change
bindufy(config=CONFIG, handler_func=handler)
bindufy(config=CONFIG, handler=handler)

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +41
from agent import AGENT_CONFIG, parse_research_response
print(f" ✓ Agent name: {AGENT_CONFIG['name']}")
print(f" ✓ Agent version: {AGENT_CONFIG['version']}")
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

This file imports AGENT_CONFIG from agent, but agent.py defines CONFIG (not AGENT_CONFIG). Running this script will always hit the exception path for the agent structure check. Update the import/printed fields to use the actual config symbol exported by agent.py (or rename the config in agent.py for consistency).

Suggested change
from agent import AGENT_CONFIG, parse_research_response
print(f" ✓ Agent name: {AGENT_CONFIG['name']}")
print(f" ✓ Agent version: {AGENT_CONFIG['version']}")
from agent import CONFIG, parse_research_response
print(f" ✓ Agent name: {CONFIG['name']}")
print(f" ✓ Agent version: {CONFIG['version']}")

Copilot uses AI. Check for mistakes.
Comment on lines +98 to +103
curl -X POST http://localhost:3773/chat \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "What are the latest developments in AI agents?"}
]
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The HTTP usage example posts to /chat with a non-JSON-RPC body, but Bindu's server routes requests through the A2A JSON-RPC endpoint at / (see other examples in examples/README.md). As written, the curl command will 404 or be rejected by the server. Update this section to use the JSON-RPC message/send payload against http://localhost:3773/ (or document the correct endpoint if you are running a different server).

Suggested change
curl -X POST http://localhost:3773/chat \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "What are the latest developments in AI agents?"}
]
curl -X POST http://localhost:3773/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "message/send",
"params": {
"messages": [
{
"role": "user",
"content": "What are the latest developments in AI agents?"
}
]
}

Copilot uses AI. Check for mistakes.

### 2. Set API Key
```powershell
$env:LLM_API_KEY='sk-your-openai-key-here'
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The quickstart uses LLM_API_KEY, but agent.py only reads OPENAI_API_KEY / OPENROUTER_API_KEY. Users following these instructions will configure the wrong variable and the agent will fail with "No LLM API key configured". Update the docs to use the environment variable names that the code actually consumes.

Suggested change
$env:LLM_API_KEY='sk-your-openai-key-here'
$env:OPENAI_API_KEY='sk-your-openai-key-here'

Copilot uses AI. Check for mistakes.
Comment on lines +189 to +192
# Send request
curl -X POST http://localhost:3773/handler \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "query"}]}'
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

This section shows running python -m bindu.server --agent agent.py and calling POST /handler with a {"messages": ...} payload. Bindu in this repo exposes the A2A JSON-RPC endpoint on POST /, and there is no /handler route in the server. Update this example to use the JSON-RPC message/send request format (as shown in examples/README.md).

Suggested change
# Send request
curl -X POST http://localhost:3773/handler \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "query"}]}'
# Send JSON-RPC request
curl -X POST http://localhost:3773/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "message/send",
"params": {
"messages": [
{
"role": "user",
"content": "query"
}
]
}
}'

Copilot uses AI. Check for mistakes.
Comment on lines +391 to +397
# Send request
curl -X POST http://localhost:3773/handler \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Your question"}
]
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The HTTP example here posts to /handler with a {"messages": ...} body, but Bindu’s server in this repo accepts A2A JSON-RPC on POST / (see examples/README.md and bindu/server/endpoints/a2a_protocol.py). As written, this curl command won’t work against the Bindu server started by bindufy. Update it to use the JSON-RPC message/send payload against /.

Suggested change
# Send request
curl -X POST http://localhost:3773/handler \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Your question"}
]
# Send request (A2A JSON-RPC message/send)
curl -X POST http://localhost:3773/ \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "1",
"method": "message/send",
"params": {
"messages": [
{"role": "user", "content": "Your question"}
]
}

Copilot uses AI. Check for mistakes.
Comment on lines +277 to +287
# Register agent with Bindu framework
# This makes the agent discoverable and deployable
bindufy(config=CONFIG, handler_func=handler)


# ============================================================================
# Demo & Testing (for local development only)
# ============================================================================

if __name__ == "__main__":
"""
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

bindufy(...) is executed at import time and (with the correct arguments) starts the server in a blocking way (run_server=True by default). That means python agent.py --demo will never reach the demo code, and test_components.py will hang when it imports agent. Gate server startup behind an if __name__ == "__main__" check (and/or pass run_server=False when importing) so the module can be imported without side effects.

Copilot uses AI. Check for mistakes.
@Paraschamoli Paraschamoli added the duplicate This issue or pull request already exists label Mar 5, 2026
@MayurUghade03
Copy link
Author

Thanks for the review and duplicate label. I understand this may overlap with existing examples. If helpful, I can narrow this PR to only unique additions (official bindu.penguin.bindufy integration, typed handler contract, cleaned README alignment, and security-focused setup). Please let me know whether you’d prefer I close this as duplicate or revise scope to match project needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants