Commit 678bbd8
fix(agent_loop): apply agent_before hook return value to context
The plugin hook system in plugins/hooks.py already supports returning a
dict to mutate the agent context, but agent_runner_loop() discarded the
return value of _hook('agent_before', ...). This prevented plugins from
modifying system_prompt / user_input / initial_user_content.
Capture the return value; when a dict is returned, apply its overrides
to the messages list. Non-dict returns and missing keys are ignored, so
existing hooks that only inspect ctx (e.g. logging/metrics) continue to
work without modification.
Closes #5371 parent 2057d86 commit 678bbd8
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| |||
0 commit comments