mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 05:42:54 -07:00
fix: report AgentExecutionBlocked in non-interactive programmatic modes (#26262)
This commit is contained in:
@@ -378,7 +378,7 @@ describe('translateEvent', () => {
|
||||
expect(err.type).toBe('error');
|
||||
expect(err.fatal).toBe(false);
|
||||
expect(err._meta?.['code']).toBe('AGENT_EXECUTION_BLOCKED');
|
||||
expect(err.message).toBe('Agent execution blocked: Policy violation');
|
||||
expect(err.message).toBe('Policy violation');
|
||||
});
|
||||
|
||||
it('uses systemMessage in the final error message when available', () => {
|
||||
@@ -393,9 +393,7 @@ describe('translateEvent', () => {
|
||||
};
|
||||
const result = translateEvent(event, state);
|
||||
const err = result[0] as AgentEvent<'error'>;
|
||||
expect(err.message).toBe(
|
||||
'Agent execution blocked: Blocked by policy hook',
|
||||
);
|
||||
expect(err.message).toBe('Blocked by policy hook');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ export function translateEvent(
|
||||
out.push(
|
||||
makeEvent('error', state, {
|
||||
status: 'PERMISSION_DENIED',
|
||||
message: `Agent execution blocked: ${event.value.systemMessage?.trim() || event.value.reason}`,
|
||||
message: event.value.systemMessage?.trim() || event.value.reason,
|
||||
fatal: false,
|
||||
_meta: { code: 'AGENT_EXECUTION_BLOCKED' },
|
||||
}),
|
||||
|
||||
@@ -647,7 +647,7 @@ describe('LegacyAgentSession', () => {
|
||||
e.type === 'error' && e._meta?.['code'] === 'AGENT_EXECUTION_BLOCKED',
|
||||
);
|
||||
expect(blocked?.fatal).toBe(false);
|
||||
expect(blocked?.message).toBe('Agent execution blocked: Blocked by hook');
|
||||
expect(blocked?.message).toBe('Blocked by hook');
|
||||
|
||||
const messages = events.filter(
|
||||
(e): e is AgentEvent<'message'> =>
|
||||
|
||||
Reference in New Issue
Block a user