Pause data generation for human review
This commit is contained in:
@@ -274,6 +274,59 @@ class AgentRuntimeTests(unittest.TestCase):
|
||||
self.assertGreaterEqual(len(result.transcript), 5)
|
||||
self.assertGreaterEqual(len(result.file_history), 0)
|
||||
|
||||
def test_agent_stops_after_data_agent_plan_requires_review(self) -> None:
|
||||
responses = [
|
||||
{
|
||||
'choices': [
|
||||
{
|
||||
'message': {
|
||||
'role': 'assistant',
|
||||
'content': 'I will prepare a reviewable plan.',
|
||||
'tool_calls': [
|
||||
{
|
||||
'id': 'call_1',
|
||||
'type': 'function',
|
||||
'function': {
|
||||
'name': 'data_agent_prepare_generation_plan',
|
||||
'arguments': json.dumps(
|
||||
{
|
||||
'dataset_label': '地图和生活边界数据',
|
||||
'target': 'Agent(tag="life_service")',
|
||||
'total_count': 2,
|
||||
'turn_mix': '1 条单轮,1 条多轮',
|
||||
'coverage': '附近吃喝玩乐',
|
||||
'exclusions': '不要生成导航路线类 query',
|
||||
'output_path': 'tasks/demo/artifacts',
|
||||
}
|
||||
),
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
'finish_reason': 'tool_calls',
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
workspace = Path(tmp_dir)
|
||||
with patch('src.openai_compat.request.urlopen', side_effect=make_urlopen_side_effect(responses)):
|
||||
agent = LocalCodingAgent(
|
||||
model_config=ModelConfig(
|
||||
model='Qwen/Qwen3-Coder-30B-A3B-Instruct',
|
||||
base_url='http://127.0.0.1:8000/v1',
|
||||
),
|
||||
runtime_config=AgentRuntimeConfig(cwd=workspace),
|
||||
)
|
||||
result = agent.run('Prepare data generation plan')
|
||||
|
||||
self.assertEqual(result.stop_reason, 'user_review_required')
|
||||
self.assertEqual(result.tool_calls, 1)
|
||||
self.assertIn('本轮已暂停', result.final_output)
|
||||
self.assertTrue(
|
||||
any(event.get('type') == 'user_review_required' for event in result.events)
|
||||
)
|
||||
|
||||
def test_write_tool_is_blocked_without_permission(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
config = AgentRuntimeConfig(cwd=Path(tmp_dir))
|
||||
|
||||
Reference in New Issue
Block a user