Skip to content

feat(adapter): include matched rule, reason, and fix suggestion in deny feedback#58

Merged
fohte merged 1 commit intomainfrom
fohte/impl-runok-init-deny-feedback
Feb 20, 2026
Merged

feat(adapter): include matched rule, reason, and fix suggestion in deny feedback#58
fohte merged 1 commit intomainfrom
fohte/impl-runok-init-deny-feedback

Conversation

@fohte
Copy link
Owner

@fohte fohte commented Feb 20, 2026

Why

  • LLM agents should be able to identify which rule denied a command and how to fix it

What

  • Structure ExecAdapter deny stderr output to show matched rule, reason, and fix suggestion on separate lines
  • Include matched rule, message, and fix suggestion in ClaudeCodeHookAdapter's permissionDecisionReason

Open with Devin

ExecAdapter's deny output did not show the matched rule pattern,
making it hard for LLM agents to understand why a command was rejected
and how to fix it. HookAdapter's permissionDecisionReason only included
the message but omitted the matched rule and fix_suggestion.

ExecAdapter now outputs a structured format:
  runok: denied: <matched_rule>
    reason: <message>
    suggestion: <fix_suggestion>

HookAdapter now builds a combined reason string that includes the
matched rule, message, and fix_suggestion in permissionDecisionReason.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@gemini-code-assist
Copy link

Summary of Changes

Hello @fohte, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the clarity and detail of deny feedback across different adapters. By structuring the output for ExecAdapter and consolidating information for ClaudeCodeHookAdapter, it enables better understanding for both human users and LLM agents regarding why a command was denied and how it might be resolved. The changes focus on providing actionable insights rather than generic denial messages.

Highlights

  • Enhanced Deny Feedback in ExecAdapter: The ExecAdapter now provides more structured feedback to stderr when a command is denied, explicitly separating the matched rule, reason, and fix suggestion onto different lines.
  • Improved Deny Reason for ClaudeCodeHookAdapter: The ClaudeCodeHookAdapter now includes the matched rule, message, and fix suggestion within its permissionDecisionReason string, offering a more comprehensive explanation for denied actions.
  • New Helper Function for Deny Reasons: A new private helper function, build_deny_reason, was introduced to consistently format deny responses into a single, informative string.
Changelog
  • src/adapter/exec_adapter.rs
    • Refactored the stderr output for denied commands to provide more structured feedback including the matched rule, reason, and fix suggestion.
  • src/adapter/hook_adapter.rs
    • Imported DenyResponse for use in the adapter.
    • Added build_deny_reason function to format deny responses into a single string.
    • Modified ClaudeCodeHookAdapter to use build_deny_reason for permissionDecisionReason when an action is denied.
    • Updated and added test cases to validate the new deny reason formatting.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully improves the feedback provided when a command is denied by including the matched rule, an optional reason, and an optional fix suggestion. These changes are correctly implemented in both ExecAdapter for CLI output and ClaudeCodeHookAdapter for JSON-based hook responses. The implementation is clean, maintains consistency with existing patterns, and includes appropriate test coverage for the new message formats. No significant issues or bugs were identified during the review.

@fohte fohte merged commit bd8f929 into main Feb 20, 2026
5 checks passed
@fohte fohte deleted the fohte/impl-runok-init-deny-feedback branch February 20, 2026 15:26
@fohte-bot fohte-bot bot mentioned this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant