anthropics / anthropics/financial-services

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

未关闭
#99 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
34.8k
派生
5.2k
平均合并
2 小时 2 分钟
30 天内合并 PR
3

描述

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.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。