anthropics / anthropics/financial-services
Critical Bug: Broken cross-agent handoffs due to truncated JSON extraction in orchestrate.py
- 主要言語
- Python
- スター
- 34.8k
- フォーク
- 5.2k
- 平均マージ
- 2時間 2分
- マージ済み PR(30日)
- 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 はまだ評価されていません。