Add multilingual collab agent example - #427
Conversation
📝 WalkthroughWalkthroughAdded a new example "multilingual-collab-agent" that provides a runnable Bindu-based multilingual agent (English/Hindi/Bengali) with web research (DuckDuckGo), translation, collaborative drafting skills, optional Mem0 persistent memory, and configuration to use an OpenRouter-compatible model. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server as "bindufy / main.py"
participant Agent
participant Model as "OpenRouter Model"
participant Tools as "DuckDuckGo"
participant Mem as "Mem0 (optional)"
rect rgba(0,128,0,0.5)
Client->>Server: POST messages
end
Server->>Agent: handler(messages)
alt Agent not initialized
Server->>Agent: acquire _init_lock / build_agent()
Agent->>Model: configure using MODEL_NAME & OPENROUTER_API_KEY
Agent->>Tools: attach DuckDuckGoTools
opt MEM0_API_KEY set
Agent->>Mem: initialize Mem0Tools
end
Agent-->>Server: ready
end
Server->>Agent: forward messages
Agent->>Model: generate response (may call Tools / Mem)
Agent->>Tools: perform web search (Read)
opt Mem enabled
Agent->>Mem: Read/Write memory
end
Model-->>Agent: response
Agent-->>Server: reply payload
Server-->>Client: HTTP response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (2)
examples/multilingual-collab-agent/.gitignore (1)
1-5: Ignore local virtualenv directory created by setup steps.
README.mdinstructs creating.venvin this folder, but.venv/is not ignored here.♻️ Suggested patch
.env .bindu/ +.venv/ __pycache__/ *.pyc *.pem🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/multilingual-collab-agent/.gitignore` around lines 1 - 5, The .gitignore in examples/multilingual-collab-agent is missing the local virtualenv entry described in README; update the .gitignore by adding the .venv/ pattern so the local virtual environment created by setup (named .venv) is ignored — modify the same .gitignore file (which currently lists .env, .bindu/, __pycache__/, *.pyc, *.pem) to include .venv/ to prevent committing the virtualenv.examples/multilingual-collab-agent/main.py (1)
64-65: Catch specific exception types instead of broadExceptionThe Mem0Tools wrapper raises only
ImportError(missing dependency) andConnectionError(initialization failures including invalid API key, auth errors, and network issues). Replaceexcept Exceptionwithexcept (ImportError, ConnectionError)to avoid masking unexpected bugs unrelated to Mem0 availability.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/multilingual-collab-agent/main.py` around lines 64 - 65, Replace the broad except Exception block that surrounds the Mem0Tools import/initialization with a specific exception handler: catch only ImportError and ConnectionError (i.e., use except (ImportError, ConnectionError) as e) so that only expected Mem0 tools failures are handled and other unexpected exceptions are not masked; update the print/log line in that except block to use the same exception variable (e) for the message.
🤖 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/multilingual-collab-agent/agent_config.json`:
- Around line 24-33: The default config is too permissive: set "debug_mode" to
false and lower/remove "debug_level"; change "deployment.url" from
"http://0.0.0.0:3773" to a loopback address (e.g., "http://127.0.0.1:3773"); set
"deployment.expose" to false; replace "deployment.cors_origins" wildcard ["*"]
with a limited list or empty array; and restrict "deployment.proxy_urls" from
"0.0.0.0" to explicit allowed proxy hosts or an empty list so the example uses a
safe, local-only posture by default.
In `@examples/multilingual-collab-agent/main.py`:
- Around line 53-59: The code currently treats mem0_api_key as required and
raises ValueError, preventing the optional-memory fallback; change the logic so
MEM0_API_KEY is optional: do not raise when mem0_api_key is missing, keep
mem0_api_key as None (or empty string) and let build_agent(handle memory) accept
a missing mem0_api_key and fall back to the "no memory" path; update any startup
message that claims memory is enabled (the log emitted from build_agent/startup)
to conditionally reflect whether mem0_api_key is present and memory will be
used. Ensure you reference and modify checks around the mem0_api_key variable
and the build_agent invocation/logging to implement this behavior.
- Line 173: The two print statements using an unnecessary f-string prefix (e.g.,
the print call that outputs " Supported languages: English, Hindi (हिन्दी),
Bengali (বাংলা)" and the similar print on line 175) should drop the leading "f"
since there is no interpolation; update those calls in main.py (the prints in
the main script / function that prints supported languages) to use plain string
literals without the f-prefix to resolve Ruff F541.
In `@examples/multilingual-collab-agent/README.md`:
- Around line 89-91: Replace the bind-all address literal "http://0.0.0.0:3773"
in the README with a loopback address for browser guidance — use
"http://127.0.0.1:3773" or "http://localhost:3773" instead; locate the exact
string "http://0.0.0.0:3773" in the README and update it to the preferred
loopback form so instructions are safe for users to open in a browser.
- Around line 12-203: The README contains machine-specific absolute links (e.g.,
/F:/Bindu/examples/multilingual-collab-agent/main.py) — replace all absolute
file URLs with repo-relative paths (e.g., ./main.py, ./agent_config.json,
./requirements.txt, .env.example, and skills/research/skill.yaml etc.) so links
work for other users; update every occurrence in the file (references in the
header, Project Structure, “How It Works”, and any inline code blocks) to use
relative link syntax that points to files inside the repository rather than
absolute filesystem paths.
In `@examples/multilingual-collab-agent/requirements.txt`:
- Around line 3-24: The requirements.txt is missing mem0ai and uses the wrong
DuckDuckGo package name; add mem0ai to the file and replace the ddgs entry with
the package and version used in skills/research/skill.yaml
(duckduckgo-search>=8.1.1) so installations for imports in main.py (mem0ai) and
the research skill (duckduckgo-search) succeed.
---
Nitpick comments:
In `@examples/multilingual-collab-agent/.gitignore`:
- Around line 1-5: The .gitignore in examples/multilingual-collab-agent is
missing the local virtualenv entry described in README; update the .gitignore by
adding the .venv/ pattern so the local virtual environment created by setup
(named .venv) is ignored — modify the same .gitignore file (which currently
lists .env, .bindu/, __pycache__/, *.pyc, *.pem) to include .venv/ to prevent
committing the virtualenv.
In `@examples/multilingual-collab-agent/main.py`:
- Around line 64-65: Replace the broad except Exception block that surrounds the
Mem0Tools import/initialization with a specific exception handler: catch only
ImportError and ConnectionError (i.e., use except (ImportError, ConnectionError)
as e) so that only expected Mem0 tools failures are handled and other unexpected
exceptions are not masked; update the print/log line in that except block to use
the same exception variable (e) for the message.
🪄 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: 07b60b6c-199f-44b4-bbb3-fdf460ad537c
📒 Files selected for processing (9)
examples/multilingual-collab-agent/.env.exampleexamples/multilingual-collab-agent/.gitignoreexamples/multilingual-collab-agent/README.mdexamples/multilingual-collab-agent/agent_config.jsonexamples/multilingual-collab-agent/main.pyexamples/multilingual-collab-agent/requirements.txtexamples/multilingual-collab-agent/skills/collaborate/skill.yamlexamples/multilingual-collab-agent/skills/research/skill.yamlexamples/multilingual-collab-agent/skills/translate/skill.yaml
|
The failing tests appear unrelated to this example PR:
I’m updating the example-specific review feedback separately. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
examples/multilingual-collab-agent/main.py (1)
158-159: Add assertion for type safety after lazy initialization.While runtime-safe due to the
_initializedflag, type checkers may warn thatagentcould beNone. An assertion provides explicit type narrowing.💡 Optional: Add type assertion
async with _init_lock: if not _initialized: print("Initializing multilingual agent...") agent = build_agent() _initialized = True print("Agent initialized") + assert agent is not None, "Agent should be initialized" response = await agent.arun(input) return response🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/multilingual-collab-agent/main.py` around lines 158 - 159, Add an explicit runtime assertion after the lazy initialization to reassure type checkers that `agent` is non-None: after the code path that sets `_initialized` and constructs `agent` (the variable used to call `agent.arun(messages)`), insert an assertion like `assert agent is not None` before `response = await agent.arun(messages)` so static analyzers know `agent` has been narrowed to a concrete type when calling `arun`.examples/multilingual-collab-agent/README.md (1)
66-78: Consider adding Unix/macOS setup instructions alongside PowerShell.The setup section only includes PowerShell commands. For cross-platform usability, consider adding bash equivalents:
💡 Optional: Add bash instructions
From `examples/multilingual-collab-agent`, run: +**PowerShell (Windows):** + ```powershell python -m venv .venv .\.venv\Scripts\Activate.ps1 pip install -r requirements.txt Copy-Item .env.example .env
+Bash (Linux/macOS):
+
+bash +python -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +cp .env.example .env +</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@examples/multilingual-collab-agent/README.mdaround lines 66 - 78, Update
the "Setup" section's PowerShell-only instructions to include equivalent
Unix/macOS bash commands so cross-platform users can follow along; add a new
subsection (e.g., "Bash (Linux/macOS)") under the existing "Setup" header with
the corresponding bash steps: create a virtualenv, activate it with source
.venv/bin/activate, install requirements with pip install -r requirements.txt,
and copy .env.example to .env (cp .env.example .env), mirroring the existing
PowerShell steps in the README's Setup block.</details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against the current code and only fix it if needed.
Inline comments:
In@examples/multilingual-collab-agent/main.py:
- Around line 147-159: Rename the handler function's first parameter from
messages to input so it satisfies bindufy()'s signature check: update async def
handler(messages: list[dict[str, str]]) -> Any to async def handler(input:
list[dict[str, str]]) -> Any and then update all uses inside the function
(including the call to agent.arun) to reference input instead of messages; keep
the rest of the function (agent, _init_lock, _initialized, build_agent,
agent.arun) unchanged.
Nitpick comments:
In@examples/multilingual-collab-agent/main.py:
- Around line 158-159: Add an explicit runtime assertion after the lazy
initialization to reassure type checkers thatagentis non-None: after the
code path that sets_initializedand constructsagent(the variable used to
callagent.arun(messages)), insert an assertion likeassert agent is not Nonebeforeresponse = await agent.arun(messages)so static analyzers know
agenthas been narrowed to a concrete type when callingarun.In
@examples/multilingual-collab-agent/README.md:
- Around line 66-78: Update the "Setup" section's PowerShell-only instructions
to include equivalent Unix/macOS bash commands so cross-platform users can
follow along; add a new subsection (e.g., "Bash (Linux/macOS)") under the
existing "Setup" header with the corresponding bash steps: create a virtualenv,
activate it with source .venv/bin/activate, install requirements with pip
install -r requirements.txt, and copy .env.example to .env (cp .env.example
.env), mirroring the existing PowerShell steps in the README's Setup block.</details> <details> <summary>🪄 Autofix (Beta)</summary> Fix all unresolved CodeRabbit comments on this PR: - [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended) - [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes </details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro **Run ID**: `65756228-3f41-45da-bb87-55d618c76d54` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 91187a35f89dae97bde33a45b64c41e9b87d23f2 and e5e96171c3725e9c70043c5b377e1b40532c4933. </details> <details> <summary>📒 Files selected for processing (4)</summary> * `examples/multilingual-collab-agent/README.md` * `examples/multilingual-collab-agent/agent_config.json` * `examples/multilingual-collab-agent/main.py` * `examples/multilingual-collab-agent/requirements.txt` </details> <details> <summary>✅ Files skipped from review due to trivial changes (1)</summary> * examples/multilingual-collab-agent/requirements.txt </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary> * examples/multilingual-collab-agent/agent_config.json </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
| async def handler(messages: list[dict[str, str]]) -> Any: | ||
| """Handle incoming messages and initialize the agent lazily.""" | ||
| global agent, _initialized | ||
|
|
||
| async with _init_lock: | ||
| if not _initialized: | ||
| print("Initializing multilingual agent...") | ||
| agent = build_agent() | ||
| _initialized = True | ||
| print("Agent initialized") | ||
|
|
||
| response = await agent.arun(messages) | ||
| return response |
There was a problem hiding this comment.
Handler parameter must be named input, not messages.
The bindufy() function validates handler signatures and requires the parameter to be named input. Per bindu/penguin/manifest.py, the validation will raise:
ValueError: First parameter must be named 'input', got 'messages'
This will cause the agent to fail at startup.
🐛 Proposed fix
-async def handler(messages: list[dict[str, str]]) -> Any:
+async def handler(input: list[dict[str, str]]) -> Any:
"""Handle incoming messages and initialize the agent lazily."""
global agent, _initialized
async with _init_lock:
if not _initialized:
print("Initializing multilingual agent...")
agent = build_agent()
_initialized = True
print("Agent initialized")
- response = await agent.arun(messages)
+ response = await agent.arun(input)
return response📝 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.
| async def handler(messages: list[dict[str, str]]) -> Any: | |
| """Handle incoming messages and initialize the agent lazily.""" | |
| global agent, _initialized | |
| async with _init_lock: | |
| if not _initialized: | |
| print("Initializing multilingual agent...") | |
| agent = build_agent() | |
| _initialized = True | |
| print("Agent initialized") | |
| response = await agent.arun(messages) | |
| return response | |
| async def handler(input: list[dict[str, str]]) -> Any: | |
| """Handle incoming messages and initialize the agent lazily.""" | |
| global agent, _initialized | |
| async with _init_lock: | |
| if not _initialized: | |
| print("Initializing multilingual agent...") | |
| agent = build_agent() | |
| _initialized = True | |
| print("Agent initialized") | |
| response = await agent.arun(input) | |
| return response |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@examples/multilingual-collab-agent/main.py` around lines 147 - 159, Rename
the handler function's first parameter from messages to input so it satisfies
bindufy()'s signature check: update async def handler(messages: list[dict[str,
str]]) -> Any to async def handler(input: list[dict[str, str]]) -> Any and then
update all uses inside the function (including the call to agent.arun) to
reference input instead of messages; keep the rest of the function (agent,
_init_lock, _initialized, build_agent, agent.arun) unchanged.
|
Superseded by #429, which contains the updated branch and latest changes for this example. Closing this duplicate. |
Summary
Describe the problem and fix in 2–5 bullets:
examples/multilingual-collab-agent/example with agent implementation, config, env template, requirements, three skill manifests, and a README.Change Type (select all that apply)
Scope (select all touched areas)
Linked Issue/PR
User-Visible / Behavior Changes
examples/multilingual-collab-agentSecurity Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation: NoneVerification
Environment
.venvPython 3.12Steps to Test
examples/multilingual-collab-agentmain.py,agent_config.json, skill manifests, andREADME.mdExpected Behavior
Actual Behavior
examples/multilingual-collab-agentEvidence (attach at least one)
Human Verification (required)
What you personally verified (not just CI):
frontend/svelte.config.jsanduv.lockCompatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
91187a3or removeexamples/multilingual-collab-agentexamples/multilingual-collab-agent/*Risks and Mitigations
examples/and can be updated independently without affecting core runtime behaviorChecklist
uv run pytest)uv run pre-commit run --all-files)Summary by CodeRabbit
New Features
Documentation
Chores
New Skills