Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion agent_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ def agent_runner_loop(client, system_prompt, user_input, handler, tools_schema,
{"role": "user", "content": initial_user_content if initial_user_content is not None else user_input}
]
turn = 0; handler.max_turns = max_turns
_hook('agent_before', locals())
_ctx = _hook('agent_before', locals()) # plugins may return dict to override system_prompt/user_input
if isinstance(_ctx, dict):
if 'system_prompt' in _ctx:
system_prompt = _ctx['system_prompt']
messages[0]['content'] = system_prompt
if _ctx.get('initial_user_content') is not None:
messages[1]['content'] = _ctx['initial_user_content']
elif 'user_input' in _ctx and initial_user_content is None:
messages[1]['content'] = _ctx['user_input']
while turn < handler.max_turns:
turn += 1; turnstr = f'LLM Running (Turn {turn}) ...'
if handler.parent.task_dir: turnstr = f'Turn {turn} ...'
Expand Down