-
Notifications
You must be signed in to change notification settings - Fork 418
Improve tool-denial failure report formatting for last denied request #38101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,14 @@ | |
| > [!WARNING] | ||
| > **Excessive Tool Denials**: The Copilot SDK hit the max tool denial guardrail and stopped the session early (`{denial_count}/{threshold}`). | ||
|
|
||
| **Last denied request:** | ||
| <details> | ||
| <summary><strong>Last denied request</strong></summary> | ||
|
|
||
| ```text | ||
| {reason} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Raw substitution of
💡 Suggested fixSanitize the reason before substitution in the caller: reason: normalizedReason.replace(/`{3,}/g, "``"),Or add a dedicated escaping step in |
||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| This is a structured guardrail event (`guard.tool_denials_exceeded`) captured in `events.jsonl`. | ||
|
|
||
|
|
@@ -16,7 +22,8 @@ Update the workflow prompt and/or permissions so required actions are permitted: | |
|
|
||
| ``` | ||
| The workflow {workflow_id} stopped because the Copilot SDK exceeded its tool denial threshold ({denial_count}/{threshold}). | ||
| Last denied request: {reason} | ||
| Last denied request: | ||
| {reason} | ||
|
|
||
| Please update the workflow so the prompt only uses tools permitted by the workflow tool policy. | ||
| ``` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary behavioral change (fallback removal) has zero test coverage.
These new assertions verify the happy-path template rendering, but there is no test for what happens when
getPromptPathorfs.readFileSyncfails. That is the key semantic change in this patch: previously the function returned a hardcoded fallback string on any template error; now it throws. A missing test means the regression described in thehandle_agent_failure.cjscomment can re-emerge silently.💡 Suggested fix
Add a test that stubs the file system to throw and asserts the function still produces output rather than propagating the exception — or, if the new intent is to let it throw, document that explicitly with a test asserting the exception type so the caller contract is locked:
Without a test in either direction, this edge case is invisible to future refactors.