feat/multi-agent #5

Open
brent.edwards wants to merge 10 commits from feat/multi-agent into master
Member

Multiple changes made by Aditya.

Multiple changes made by Aditya.
aditya was assigned by brent.edwards 2025-10-03 16:23:52 +00:00
brent.edwards left a comment
Author
Member

Good work, Aditya!

Remember that new code needs to match mypy --strict and pylint code guidelines.

Good work, Aditya! Remember that new code needs to match `mypy --strict` and `pylint` code guidelines.
@ -0,0 +2,4 @@
A powerful, reactive Agent Framework using RxPy streams for complex AI agent orchestration and message routing.
[![PyPI Package](https://img.shields.io/pypi/v/cleveragents.svg)](https://pypi.org/project/cleveragents/)
Author
Member

This leads to a 404 error.

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.
[![PyPI Package](https://img.shields.io/pypi/v/cleveragents.svg)](https://pypi.org/project/cleveragents/)
[![Travis-CI Build Status](https://img.shields.io/travis/cleverthis/cleveragents.svg)](https://travis-ci.org/cleverthis/cleveragents)
Author
Member

This also leads to a 404 error.

This also leads to a 404 error.
@ -0,0 +29,4 @@
### Install from PyPI
```bash
pip install cleveragents
Author
Member

Here's what happens when I try this command:

❯ pip install cleveragents
ERROR: Could not find a version that satisfies the requirement cleveragents (from versions: none)

[notice] A new release of pip is available: 25.0.1 -> 25.2
[notice] To update, run: pip install --upgrade pip
ERROR: No matching distribution found for cleveragents
Here's what happens when I try this command: ``` ❯ pip install cleveragents ERROR: Could not find a version that satisfies the requirement cleveragents (from versions: none) [notice] A new release of pip is available: 25.0.1 -> 25.2 [notice] To update, run: pip install --upgrade pip ERROR: No matching distribution found for cleveragents ```
@ -0,0 +210,4 @@
provider: openai
model: gpt-4
api_key: "sk-your-key-here"
```
Author
Member

Information about configuration files can already be found in lines 92-110.

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
Author
Member

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:

Failing scenarios:
  tests/features/application_missing_lines_coverage.feature:154  Subscription re-setup after operations lines 644-648
  tests/features/tool_agent.feature:84  Tool Agent shell command execution

73 features passed, 2 failed, 0 skipped
1217 scenarios passed, 2 failed, 0 skipped
6559 steps passed, 2 failed, 0 skipped
Took 0min 49.345s

The tests need to pass before we can move forward.

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: ``` Failing scenarios: tests/features/application_missing_lines_coverage.feature:154 Subscription re-setup after operations lines 644-648 tests/features/tool_agent.feature:84 Tool Agent shell command execution 73 features passed, 2 failed, 0 skipped 1217 scenarios passed, 2 failed, 0 skipped 6559 steps passed, 2 failed, 0 skipped Took 0min 49.345s ``` 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
Author
Member
  1. pytest is not installed.
  2. After I install pytest, I get the following problems:
 python -m pytest --cov=cleveragents
ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...]
__main__.py: error: unrecognized arguments: --cov=cleveragents
  inifile: /home/brent.edwards/Workspace/cleveragents-core/setup.cfg
  rootdir: /home/brent.edwards/Workspace/cleveragents-core
  1. The tests appear to mostly be based on behave not pytest.

I guess that you could use coverage.py but I had problems running it.

1. `pytest` is not installed. 2. After I install `pytest`, I get the following problems: ``` python -m pytest --cov=cleveragents ERROR: usage: __main__.py [options] [file_or_dir] [file_or_dir] [...] __main__.py: error: unrecognized arguments: --cov=cleveragents inifile: /home/brent.edwards/Workspace/cleveragents-core/setup.cfg rootdir: /home/brent.edwards/Workspace/cleveragents-core ``` 3. The tests appear to mostly be based on `behave` not `pytest`. 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
Author
Member

Running tox gives the following problem in the middle:

lists of files in version control and sdist do not match!
missing from VCS:
  examples/documents/BusinessServiceAgreement.docx
  examples/documents/BusinessServiceAgreement.txt
missing from sdist:
  README.md
check: exit 1 (1.61 seconds) /home/brent.edwards/Workspace/cleveragents-core> check-manifest /home/brent.edwards/Workspace/cleveragents-core pid=469604

and the tests run endlessly but it occasionally pauses with the message

Failing scenarios:
  tests/features/application_missing_lines_coverage.feature:154  Subscription re-setup after operations lines 644-648
  tests/features/tool_agent.feature:84  Tool Agent shell command execution

73 features passed, 2 failed, 0 skipped
1217 scenarios passed, 2 failed, 0 skipped
6559 steps passed, 2 failed, 0 skipped
Took 0min 49.383s
py311-nocov: exit 1 (122.66 seconds) /home/brent.edwards/Workspace/cleveragents-core> behave tests/features pid=485307
py311-nocov: FAIL ✖ in 2 minutes 13.48 seconds

regularly.

Running `tox` gives the following problem in the middle: ``` lists of files in version control and sdist do not match! missing from VCS: examples/documents/BusinessServiceAgreement.docx examples/documents/BusinessServiceAgreement.txt missing from sdist: README.md check: exit 1 (1.61 seconds) /home/brent.edwards/Workspace/cleveragents-core> check-manifest /home/brent.edwards/Workspace/cleveragents-core pid=469604 ``` and the tests run endlessly but it occasionally pauses with the message ``` Failing scenarios: tests/features/application_missing_lines_coverage.feature:154 Subscription re-setup after operations lines 644-648 tests/features/tool_agent.feature:84 Tool Agent shell command execution 73 features passed, 2 failed, 0 skipped 1217 scenarios passed, 2 failed, 0 skipped 6559 steps passed, 2 failed, 0 skipped Took 0min 49.383s py311-nocov: exit 1 (122.66 seconds) /home/brent.edwards/Workspace/cleveragents-core> behave tests/features pid=485307 py311-nocov: FAIL ✖ in 2 minutes 13.48 seconds ``` regularly.
@ -0,0 +41,4 @@
- sources: [source_streams]
target: target_stream
splits:
Author
Member

Is splits required or optional?

Is `splits` required or optional?
@ -0,0 +61,4 @@
global:
variable_name: value
```
Author
Member

There should be a section about global configuration here.

It should include links to documentation of Jinja and Mustache.

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
```
Author
Member

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.

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
```
Author
Member

Could you explain here what a composite agent is?

What does it do, why is it important?

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
Author
Member

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.

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
Author
Member

Could you link to where there's more documentation for the functions? I suspect that will be very important to programmers.

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"
```
Author
Member

Could you point to where someone can find more details on entry_point and edges -- the central point of a graph?

Could you point to where someone can find more details on `entry_point` and `edges` -- the central point of a graph?
@ -0,0 +253,4 @@
preserve_subscriptions: true
preserve_checkpointing: true
```
Author
Member

Could you point to where people can find more information about bridge routes?

Could you point to where people can find more information about bridge routes?
@ -0,0 +1,190 @@
agents:
Author
Member

Is this the latest version of the code? For example, this code doesn't seem to write its analysis to a file.

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
Author
Member

As part of this header, could you mention that this code needs the --unsafe flag?

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):
Author
Member

Just FYI -- pylint requires a docstring for methods, and a return value.

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)
Author
Member

This code changes the program's behavior. Could you write a quick test that covers this change?

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)
Author
Member

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?

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:
Author
Member

By the way, thank you very much for the test_json_sanitation.py file!

This method could be static.

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
Author
Member

src/cleveragents/core/application.py:680:8: C0415: Import outside toplevel (re) (import-outside-toplevel)

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
Author
Member

src/cleveragents/core/application.py:681:8: C0415: Import outside toplevel (json) (import-outside-toplevel)

src/cleveragents/core/application.py:681:8: C0415: Import outside toplevel (json) (import-outside-toplevel)
@ -671,0 +679,4 @@
"""
import re
import json
Author
Member

src/cleveragents/core/application.py:682:0: C0303: Trailing whitespace (trailing-whitespace)

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
Author
Member

src/cleveragents/core/application.py:689:0: C0303: Trailing whitespace (trailing-whitespace)

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
Author
Member

src/cleveragents/core/application.py:692:0: C0303: Trailing whitespace (trailing-whitespace)

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):
Author
Member

src/cleveragents/core/application.py:693: error: Function is missing a type annotation [no-untyped-def]

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)
Author
Member

src/cleveragents/core/application.py:698:0: C0303: Trailing whitespace (trailing-whitespace)

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
Author
Member

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.)

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[^"]*)*)"'
Author
Member

You write pattern twice; only the second one is used. You should remove this variable.

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:
Author
Member

src/cleveragents/core/application.py:724:4: R0914: Too many local variables (17/15) (too-many-locals)

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
Author
Member

src/cleveragents/core/application.py:730:8: C0415: Import outside toplevel (re) (import-outside-toplevel)

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
Author
Member

src/cleveragents/core/application.py:731:8: C0415: Import outside toplevel (json) (import-outside-toplevel)

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
Author
Member

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)

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):
Author
Member

The parameters will need types:

src/cleveragents/core/application.py:737: error: Function is missing a type annotation [no-untyped-def]

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()
Author
Member

loop is never used.

`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
Author
Member

src/cleveragents/core/application.py:760:20: C0415: Import outside toplevel (concurrent.futures) (import-outside-toplevel)

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}"
Author
Member

It's possible that result was never filled.

It's possible that `result` was never filled.
@ -671,0 +769,4 @@
return f"\n{result}"
except Exception as e:
Author
Member

src/cleveragents/core/application.py:772:19: W0718: Catching too general exception Exception (broad-exception-caught)

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}")
Author
Member

src/cleveragents/core/application.py:773:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)

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)
Author
Member

src/cleveragents/core/application.py:793: error: Call to untyped function "execute_tool_sync" in typed context [no-untyped-call]

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}")
Author
Member

src/cleveragents/core/application.py:802:16: W1203: Use lazy % formatting in logging functions (logging-fstring-interpolation)

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"
Author
Member

src/cleveragents/core/application.py:803:28: W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)

src/cleveragents/core/application.py:803:28: W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feat/multi-agent:feat/multi-agent
git switch feat/multi-agent

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.

git switch master
git merge --no-ff feat/multi-agent
git switch feat/multi-agent
git rebase master
git switch master
git merge --ff-only feat/multi-agent
git switch feat/multi-agent
git rebase master
git switch master
git merge --no-ff feat/multi-agent
git switch master
git merge --squash feat/multi-agent
git switch master
git merge --ff-only feat/multi-agent
git switch master
git merge feat/multi-agent
git push origin master
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#5
No description provided.