| @@ -177,8 +177,9 @@ | ||
| 177 | 177 | return $rate; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $instructions = openstation_agent_get_instructions( $user->ID ); |
| 181 | + $instructions = openstation_agent_apply_vibes( $instructions, (int) $user->ID ); | |
| 181 | 182 | $abilities = openstation_agent_get_abilities( $user->ID ); |
| 182 | 183 | |
| 183 | 184 | list( $tool_defs, $slug_by_name ) = openstation_agent_runner_build_tools( $abilities ); |
| 184 | 185 | |
| @@ -967,12 +968,40 @@ | ||
| 967 | 968 | // confirmations arrive as renderable buttons, not typed-reply |
| 968 | 969 | // requests. Tool-call turns are unaffected — the model either |
| 969 | 970 | // calls a function or emits the JSON answer. |
| 970 | 971 | openstation_agent_answer_schema(), |
| 971 | - (string) $instructions . "\n\n" . openstation_agent_answer_prompt_appendix() | |
| 972 | + (string) $instructions . "\n\n" . openstation_agent_answer_prompt_appendix(), | |
| 973 | + array( 'source' => 'agents/runner' ) | |
| 972 | 974 | ); |
| 973 | 975 | } |
| 974 | 976 | ); |
| 977 | +} | |
| 978 | + | |
| 979 | +/** | |
| 980 | + * Append an agent's voice line to its instructions. | |
| 981 | + * | |
| 982 | + * **After the instructions, never before.** The two can disagree — a | |
| 983 | + * voice that says "blunt" against a workflow that says "always explain | |
| 984 | + * your reasoning" — and when they do, the workflow should win. Later | |
| 985 | + * text is the one the model weights more heavily, so position is the | |
| 986 | + * whole mechanism here. | |
| 987 | + * | |
| 988 | + * The line is stored through `openstation_agent_sanitize_vibes()`, | |
| 989 | + * which strips line breaks. That matters more than it looks: the | |
| 990 | + * composed prompt marks operator turns, and a multi-line voice line | |
| 991 | + * could otherwise fake a turn boundary. `agentsSecurity.php` pins it. | |
| 992 | + * | |
| 993 | + * @param string $instructions The agent's system prompt. | |
| 994 | + * @param int $user_id Agent user id. | |
| 995 | + * @return string | |
| 996 | + */ | |
| 997 | +function openstation_agent_apply_vibes( $instructions, $user_id ) { | |
| 998 | + $vibes = openstation_agent_get_vibes( $user_id ); | |
| 999 | + if ( '' === $vibes ) { | |
| 1000 | + return $instructions; | |
| 1001 | + } | |
| 1002 | + $line = 'Voice: ' . $vibes; | |
| 1003 | + return '' === $instructions ? $line : $instructions . "\n\n" . $line; | |
| 975 | 1004 | } |
| 976 | 1005 | |
| 977 | 1006 | /** |
| 978 | 1007 | * Run a callback with the WordPress HTTP timeout raised for the |