feat/multi-agent #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/multi-agent"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Multiple changes made by Aditya.
Good work, Aditya!
Remember that new code needs to match
mypy --strict
andpylint
code guidelines.@ -0,0 +2,4 @@
A powerful, reactive Agent Framework using RxPy streams for complex AI agent orchestration and message routing.
[](https://pypi.org/project/cleveragents/)
This leads to a 404 error.
@ -0,0 +3,4 @@
A powerful, reactive Agent Framework using RxPy streams for complex AI agent orchestration and message routing.
[](https://pypi.org/project/cleveragents/)
[](https://travis-ci.org/cleverthis/cleveragents)
This also leads to a 404 error.
@ -0,0 +29,4 @@
### Install from PyPI
```bash
pip install cleveragents
Here's what happens when I try this command:
@ -0,0 +210,4 @@
provider: openai
model: gpt-4
api_key: "sk-your-key-here"
```
Information about configuration files can already be found in lines 92-110.
@ -0,0 +273,4 @@
```bash
# Run all tests
python -m behave tests/features
Bug in the software:
With the installation as above, this command fails.
To fix it, we need to type
pip install behave
.When I run the tests, I get the following results:
The tests need to pass before we can move forward.
@ -0,0 +276,4 @@
python -m behave tests/features
# Run with coverage
python -m pytest --cov=cleveragents
pytest
is not installed.pytest
, I get the following problems:behave
notpytest
.I guess that you could use
coverage.py
but I had problems running it.@ -0,0 +279,4 @@
python -m pytest --cov=cleveragents
# Run with tox for multiple environments
tox
Running
tox
gives the following problem in the middle:and the tests run endlessly but it occasionally pauses with the message
regularly.
@ -0,0 +41,4 @@
- sources: [source_streams]
target: target_stream
splits:
Is
splits
required or optional?@ -0,0 +61,4 @@
global:
variable_name: value
```
There should be a section about global configuration here.
It should include links to documentation of Jinja and Mustache.
@ -0,0 +104,4 @@
safe_mode: true
timeout: 30
```
Can you explain what a tool agent is? The only definition so far is in
README.md
line 241.You list several tools but don't explain what they are or what they do. This is the best place to explain the basic tools.
@ -0,0 +130,4 @@
input: sub_agent1
output: sub_stream1
```
Could you explain here what a composite agent is?
What does it do, why is it important?
@ -0,0 +145,4 @@
operators:
- type: map
params:
agent: agent_name
I guess that it would be more helpful to see an example function here than an agent.
There seem to be other ways to run other agents, but I haven't yet seen a way to run simple code.
@ -0,0 +177,4 @@
- `replay`: Replay all previous values
**Operators:**
- `map`: Transform messages using agents or functions
Could you link to where there's more documentation for the functions? I suspect that will be very important to programmers.
@ -0,0 +220,4 @@
parallel_execution: true
state_class: "my_module.MyState"
```
Could you point to where someone can find more details on
entry_point
andedges
-- the central point of a graph?@ -0,0 +253,4 @@
preserve_subscriptions: true
preserve_checkpointing: true
```
Could you point to where people can find more information about bridge routes?
@ -0,0 +1,190 @@
agents:
Is this the latest version of the code? For example, this code doesn't seem to write its analysis to a file.
@ -0,0 +1,274 @@
# Multi-Agent Paper Writer - Multiple Specialized Agents Working Together
As part of this header, could you mention that this code needs the
--unsafe
flag?@ -294,7 +294,14 @@ class ReactiveCleverAgentsApp:
# Set up observers for output and errors
def on_output(msg: StreamMessage):
Just FYI --
pylint
requires a docstring for methods, and a return value.@ -298,0 +300,4 @@
print(f"\n[DEBUG] Empty output received\n")
else:
# Check for tool execution commands
processed_content = self._process_tool_commands(content_str)
This code changes the program's behavior. Could you write a quick test that covers this change?
@ -338,3 +345,3 @@
# Give streams time to process
await asyncio.sleep(0.1)
await asyncio.sleep(2.0)
FYI... I get nervous when code tries to guesstimate how long processing will take. It's always either never enough time or too much time.
Is it possible to use some signal between the stream and this code to notify when the stream is done processing?
@ -668,6 +664,151 @@ class ReactiveCleverAgentsApp:
self.langgraph_bridge.create_hybrid_pipeline(config_dict)
self.logger.debug(f"Created hybrid pipeline: {pipeline_name}")
def _sanitize_json_string(self, json_str: str) -> str:
By the way, thank you very much for the
test_json_sanitation.py
file!This method could be static.
@ -671,0 +677,4 @@
Returns:
Sanitized JSON string with control characters properly escaped
"""
import re
src/cleveragents/core/application.py:680:8: C0415: Import outside toplevel (re) (import-outside-toplevel)
@ -671,0 +678,4 @@
Sanitized JSON string with control characters properly escaped
"""
import re
import json
src/cleveragents/core/application.py:681:8: C0415: Import outside toplevel (json) (import-outside-toplevel)
@ -671,0 +679,4 @@
"""
import re
import json
src/cleveragents/core/application.py:682:0: C0303: Trailing whitespace (trailing-whitespace)
@ -671,0 +686,4 @@
return json_str # Already valid, no sanitization needed
except json.JSONDecodeError:
pass # Need to sanitize
src/cleveragents/core/application.py:689:0: C0303: Trailing whitespace (trailing-whitespace)
@ -671,0 +689,4 @@
# Strategy: Find all quoted string values and escape control characters within them
# We need to be careful to only escape content inside string values, not the JSON structure
src/cleveragents/core/application.py:692:0: C0303: Trailing whitespace (trailing-whitespace)
@ -671,0 +690,4 @@
# Strategy: Find all quoted string values and escape control characters within them
# We need to be careful to only escape content inside string values, not the JSON structure
def escape_string_content(match):
src/cleveragents/core/application.py:693: error: Function is missing a type annotation [no-untyped-def]
@ -671,0 +695,4 @@
# match.group(0) is the full match including quotes
# match.group(1) is the content inside the quotes
content = match.group(1)
src/cleveragents/core/application.py:698:0: C0303: Trailing whitespace (trailing-whitespace)
@ -671,0 +705,4 @@
content = content.replace('\b', '\\b')
content = content.replace('\f', '\\f')
content = content.replace('"', '\\"') # Escape quotes
src/cleveragents/core/application.py:708:0: C0303: Trailing whitespace (trailing-whitespace)
(I'm not going to include more of these. Use
pylint
to find all of them.)@ -671,0 +712,4 @@
# Pattern to match quoted strings (both keys and values)
# This matches: "anything including newlines and special chars"
# We use a negative lookbehind to avoid matching escaped quotes
pattern = r'"((?:[^"\\]|\\.)*)"|"([^"]*(?:\n[^"]*)*)"'
You write
pattern
twice; only the second one is used. You should remove this variable.@ -671,0 +721,4 @@
return sanitized
def _process_tool_commands(self, content: str) -> str:
src/cleveragents/core/application.py:724:4: R0914: Too many local variables (17/15) (too-many-locals)
@ -671,0 +727,4 @@
Detects [TOOL_EXECUTE:tool_name] commands and executes actual tools.
"""
import re
src/cleveragents/core/application.py:730:8: C0415: Import outside toplevel (re) (import-outside-toplevel)
@ -671,0 +728,4 @@
Detects [TOOL_EXECUTE:tool_name] commands and executes actual tools.
"""
import re
import json
src/cleveragents/core/application.py:731:8: C0415: Import outside toplevel (json) (import-outside-toplevel)
@ -671,0 +729,4 @@
"""
import re
import json
import asyncio
src/cleveragents/core/application.py:732:8: W0404: Reimport 'asyncio' (imported line 8) (reimported)
src/cleveragents/core/application.py:732:8: W0621: Redefining name 'asyncio' from outer scope (line 8) (redefined-outer-name)
@ -671,0 +734,4 @@
# Pattern to match tool execution commands
pattern = r'\[TOOL_EXECUTE:(\w+)\]\s*(\{[^}]+\})\s*\[/TOOL_EXECUTE\]'
def execute_tool_sync(tool_name, tool_params):
The parameters will need types:
src/cleveragents/core/application.py:737: error: Function is missing a type annotation [no-untyped-def]
@ -671,0 +755,4 @@
# Try to get the current running loop
try:
loop = asyncio.get_running_loop()
loop
is never used.@ -671,0 +757,4 @@
try:
loop = asyncio.get_running_loop()
# We're already in an async context, create a task
import concurrent.futures
src/cleveragents/core/application.py:760:20: C0415: Import outside toplevel (concurrent.futures) (import-outside-toplevel)
@ -671,0 +767,4 @@
# No running loop, we can use asyncio.run
result = asyncio.run(file_manager.process_message(tool_request, context))
return f"\n✅ {result}"
It's possible that
result
was never filled.@ -671,0 +769,4 @@
return f"\n✅ {result}"
except Exception as e:
src/cleveragents/core/application.py:772:19: W0718: Catching too general exception Exception (broad-exception-caught)
@ -671,0 +770,4 @@
return f"\n✅ {result}"
except Exception as e:
self.logger.error(f"Tool execution failed: {e}")
src/cleveragents/core/application.py:773:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
@ -671,0 +790,4 @@
# Sanitize JSON string before parsing to handle LLM-generated malformed JSON
sanitized_params_str = self._sanitize_json_string(tool_params_str)
tool_params = json.loads(sanitized_params_str)
tool_result = execute_tool_sync(tool_name, tool_params)
src/cleveragents/core/application.py:793: error: Call to untyped function "execute_tool_sync" in typed context [no-untyped-call]
@ -671,0 +799,4 @@
result_content[match.end():]
)
except json.JSONDecodeError as e:
self.logger.error(f"Failed to parse tool params: {e}")
src/cleveragents/core/application.py:802:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)
@ -671,0 +800,4 @@
)
except json.JSONDecodeError as e:
self.logger.error(f"Failed to parse tool params: {e}")
error_msg = f"\n❌ Error: Invalid tool parameters format"
src/cleveragents/core/application.py:803:28: W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.