-
Notifications
You must be signed in to change notification settings - Fork 3
a2a structure agent #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 pull request introduces agent-to-agent (A2A) delegation capabilities to the structure agent, enabling it to handle complex structure manipulation tasks by delegating to a remote flexible structure agent. It also adds file transfer utilities and improves environment configuration documentation.
Changes:
- Added
RemoteA2aAgentintegration to delegate complex structure tasks to aflexible_structure_agent - Implemented
get_remote_filestool for downloading files from remote agents - Updated README with clearer environment variable configuration examples
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| tools/quest/server.py | Added get_remote_files function to enable file downloads from remote agents |
| agents/MatCreator/structure_agent/agent.py | Integrated RemoteA2aAgent for delegating complex tasks and updated agent instructions |
| README.md | Improved .env configuration examples by removing unnecessary quotes from values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # get the file contents from the remote URL | ||
| response = requests.get(file_url) | ||
| response.raise_for_status() | ||
|
|
||
| # Write the raw content to file | ||
| with open(local_file_path, 'wb') as f: | ||
| f.write(response.content) | ||
|
|
||
| results.append({ | ||
| "result": "File downloaded successfully", | ||
| "file_name": file_name, | ||
| "local_path": local_file_path | ||
| }) |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function lacks proper error handling around the file operations. If an error occurs during writing (e.g., disk full, permission denied), the function will raise an unhandled exception. The partial file might be left on disk, and subsequent URLs in the list won't be processed. Consider wrapping file operations in try-except blocks and handling errors gracefully.
| def get_remote_files(file_urls: list[str], local_save_path: str="downloads") -> list[dict]: | ||
| """ | ||
| Downloads files from the remote agent to local storage. | ||
| Args: | ||
| file_urls: List of full URLs of files to download from the remote agent. | ||
| local_save_path: Local directory path to save the downloaded files. | ||
| """ | ||
| os.makedirs(local_save_path, exist_ok=True) | ||
| results: list[dict] = [] | ||
| for file_url in file_urls: | ||
| # Extract filename from URL (the last part) | ||
| file_name = file_url.split('/')[-1] | ||
| local_file_path = os.path.join(local_save_path, file_name) | ||
|
|
||
| # get the file contents from the remote URL | ||
| response = requests.get(file_url) | ||
| response.raise_for_status() | ||
|
|
||
| # Write the raw content to file | ||
| with open(local_file_path, 'wb') as f: | ||
| f.write(response.content) | ||
|
|
||
| results.append({ | ||
| "result": "File downloaded successfully", | ||
| "file_name": file_name, | ||
| "local_path": local_file_path | ||
| }) | ||
|
|
||
| return results |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new get_remote_files function lacks test coverage. Given that the repository has test coverage for structure building functions in tests/test_structure_builder.py, this new file transfer functionality should also have tests covering successful downloads, error cases (network failures, invalid URLs, file write errors), and security scenarios (path traversal attempts).
| ) | ||
| ) | ||
|
|
||
| remote_a2a_url = "http://localhost:8001" |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded URL "http://localhost:8001" will not work in production environments or when the remote agent is deployed elsewhere. This should be configurable through environment variables or configuration files to support different deployment scenarios.
| remote_a2a_url = "http://localhost:8001" | |
| remote_a2a_url = os.getenv("REMOTE_A2A_URL", "http://localhost:8001") |
| ## Tools for file transfer between local and remote structure agents | ||
| ## =============================== | ||
|
|
||
| import requests |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import statement for requests should be placed at the top of the file with other imports, not in the middle of the file before the function definition. This violates Python style guidelines (PEP 8) which recommend all imports be at the top of the file.
| local_file_path = os.path.join(local_save_path, file_name) | ||
|
|
||
| # get the file contents from the remote URL | ||
| response = requests.get(file_url) |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function lacks validation for the URL input, which could lead to security vulnerabilities. There is no check to ensure that URLs are from trusted sources or use safe protocols (e.g., only https). Additionally, there's no protection against Server-Side Request Forgery (SSRF) attacks where malicious URLs could be used to access internal resources.
| file_name = file_url.split('/')[-1] | ||
| local_file_path = os.path.join(local_save_path, file_name) |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filename extraction from the URL using file_url.split('/')[-1] is vulnerable to path traversal attacks. A malicious URL could contain path traversal sequences (e.g., '../../../etc/passwd') that would allow writing files outside the intended directory. The extracted filename should be sanitized to remove any directory separators or path traversal sequences.
| local_file_path = os.path.join(local_save_path, file_name) | ||
|
|
||
| # get the file contents from the remote URL | ||
| response = requests.get(file_url) |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HTTP request lacks a timeout parameter, which could cause the function to hang indefinitely if the remote server doesn't respond. This could lead to resource exhaustion. Add a timeout parameter to the requests.get() call to prevent hanging requests.
| response = requests.get(file_url) | |
| response = requests.get(file_url, timeout=10) |
This pull request enhances the structure agent's ability to handle complex structure-related tasks by integrating a remote agent delegation mechanism and adds new utilities for file transfer between agents. It also improves documentation and environment configuration for clarity and usability.
Agent Delegation and Remote Agent Integration:
RemoteA2aAgentand set up aflexible_structure_agentas a remote agent to handle complex structure manipulations; updated the mainstructure_agentto allow transferring tasks to this sub-agent when needed.flexible_structure_agent, ensuring users understand the agent's limitations and transfer protocol.File Transfer Utilities:
get_remote_filesintools/quest/server.pyto enable downloading files from remote agents to the local environment, facilitating smooth data transfer in multi-agent workflows.Documentation and Configuration Improvements:
.envfile example inREADME.mdfor clearer environment variable naming and usage, making setup easier for users.