anthropics / anthropics/financial-services

Critical Bug: Broken cross-agent handoffs due to truncated JSON extraction in orchestrate.py

Đang mở
#99 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
34.8k
Fork
5.2k
Merge trung bình
2 giờ 2 phút
Pull request đã merge (30 ngày)
3

Mô tả

A critical logic error was identified in the agent orchestration flow. The system fails to reliably route handoff requests between agents because the regular expression used to extract the `handoff_request `is too restrictive and fails on nested JSON structures.
## Technical Analysis
In `scripts/orchestrate.py` (lines 40-42), the regex is designed to capture the handoff payload. However, it is currently configured to stop capturing at the first closing brace (}).

Since a valid `handoff_request` contains a nested payload object, the regex terminates prematurely, leaving the JSON string malformed (missing the final outer closing brace). Consequently:

1. `json.loads()` at lines 49-52 fails.
2. The function returns None.
3. The handoff flow documented in ` managed-agent-cookbooks/*/README.md ` becomes non-functional.

## Example of the Failure
```
{
"handoff_request": {
"target_agent": "reader",
"payload": { "query": "fetch_logs" }
}
}
```
# Current Regex Behavior:
The regex stops at the first } (the one ending the nested payload).

- Captured String: `{"handoff_request": {"target_agent": "reader", "payload": {"query": "fetch_logs"}`
- Error: The final } is missing. `json.loads()` throws a `JSONDecodeError.`

## Proposed Fix

- Short term: Update the regex in scripts/orchestrate.py to be "greedy" or account for nested braces.
- Long term: Avoid using Regex to parse JSON. It is safer to use a proper JSON parser or a state-machine approach to find the start and end of the JSON block to ensure structural integrity.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.