Skip to content

feat(ponytail): AGENTS.md fallback + persona hardening + anti-hallucination - #81

Merged
getappz merged 2 commits into
masterfrom
fix/instructions-hardening
Jul 7, 2026
Merged

feat(ponytail): AGENTS.md fallback + persona hardening + anti-hallucination#81
getappz merged 2 commits into
masterfrom
fix/instructions-hardening

Conversation

@getappz

@getappz getappz commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Changes

  • AGENTS.md fallback: build() checks workspace AGENTS.md after skill cache, before embedded skill. Only uses it if contains PONYTAIL marker.
  • Persona wording: "Lazy means efficient, not careless — less work for the same result."
  • Anti-hallucination: "NEVER invent APIs, functions, or variables that don't exist. Always verify the API surface before using it."

Tickets

References

  • ponytail#291 (upstream AGENTS.md fallback)
  • ponytail#532 (upstream persona wording)
  • ponytail#504 (upstream anti-hallucination skill)

Test

  • 19/19 ponytail crate tests pass
  • Full agentflare test suite passes

Summary by CodeRabbit

  • Bug Fixes
    • Improved instruction loading by trying the cached skill content first, then—when needed—falling back to workspace guidance found via an upward search for an AGENTS.md containing the required marker.
    • If neither saved cache nor workspace guidance is available, the app continues to use the built-in default.
  • Improvements
    • Refined the fallback guidance text and expanded the “Rules” section with clearer directives on validation/error handling, security, accessibility, and API-surface compatibility.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 62f04302-4ef1-4e44-b77c-53095417b914

📥 Commits

Reviewing files that changed from the base of the PR and between bb300e6 and 61c536e.

📒 Files selected for processing (1)
  • crates/ponytail/src/instructions.rs
 __________________________________________________________________________________________________________________________
< Unix was not designed to stop its users from doing stupid things, as that would also stop them from doing clever things. >
 --------------------------------------------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
📝 Walkthrough

Walkthrough

This PR modifies crates/ponytail/src/instructions.rs. The build() function's skill-loading logic now tries skill_cache_path() first, then falls back to AGENTS.md (only if it contains a PONYTAIL marker), then defaults to the embedded skill.md. fallback_instructions() prompt text is reworded and extended with guardrail rules.

Changes

Instruction Building Updates

Layer / File(s) Summary
Skill cache and AGENTS.md fallback loading
crates/ponytail/src/instructions.rs
build() reads skill content from skill_cache_path() first, falls back to AGENTS.md only when it contains a PONYTAIL marker (returning an io::Error otherwise), and finally defaults to the embedded skill.md.
Fallback prompt text hardening
crates/ponytail/src/instructions.rs
fallback_instructions() rewords the opening "lazy senior developer" paragraph and adds new rule lines about not simplifying away validation/error handling/security/accessibility and verifying the API surface before use.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the PR’s main changes: AGENTS.md fallback, persona hardening, and anti-hallucination guardrails.
Description check ✅ Passed The description covers the changes and testing, but it does not follow the template’s Summary, Test plan checklist, and reviewer notes sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/instructions-hardening

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/ponytail/src/instructions.rs (1)

53-64: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

No test coverage for the new AGENTS.md fallback branch.

Existing tests only cover fallback_generates_for_mode and build_uses_embedded_skill (no explicit skill path, no cache, no AGENTS.md). None exercise the new middle branch: AGENTS.md present with the PONYTAIL marker, or present without the marker. Given this fallback chain is now three-tiered, targeted tests would catch regressions in ordering/marker filtering.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/ponytail/src/instructions.rs` around lines 53 - 64, Add targeted tests
for the new AGENTS.md fallback path in instructions.rs, since current coverage
only exercises fallback_generates_for_mode and build_uses_embedded_skill. Create
cases for skill_body resolution in the middle branch: one where
skill_cache_path() is missing but AGENTS.md exists with the PONYTAIL marker and
is used, and one where AGENTS.md exists without the marker and falls through to
EMBEDDED_SKILL. Use the skill_body resolution logic in instructions.rs and the
existing build/fallback helpers to verify branch ordering and marker filtering.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/ponytail/src/instructions.rs`:
- Around line 53-64: The fallback lookup in instructions.rs is resolving
AGENTS.md relative to the current process directory, which can miss the
workspace file and incorrectly fall back to EMBEDDED_SKILL. Update the
skill_body loading logic in the instructions path to resolve AGENTS.md from the
explicit workspace root or another configured base path instead of using a bare
relative path, and keep the existing PONYTAIL marker check when reading it.

---

Nitpick comments:
In `@crates/ponytail/src/instructions.rs`:
- Around line 53-64: Add targeted tests for the new AGENTS.md fallback path in
instructions.rs, since current coverage only exercises
fallback_generates_for_mode and build_uses_embedded_skill. Create cases for
skill_body resolution in the middle branch: one where skill_cache_path() is
missing but AGENTS.md exists with the PONYTAIL marker and is used, and one where
AGENTS.md exists without the marker and falls through to EMBEDDED_SKILL. Use the
skill_body resolution logic in instructions.rs and the existing build/fallback
helpers to verify branch ordering and marker filtering.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b272915b-9b71-45a1-8537-c4bf207af99d

📥 Commits

Reviewing files that changed from the base of the PR and between 7af46db and bb300e6.

📒 Files selected for processing (1)
  • crates/ponytail/src/instructions.rs

Comment thread crates/ponytail/src/instructions.rs
getappz added 2 commits July 7, 2026 23:08
…nation

- AGENTS.md as fallback: checked after skill cache, before embedded skill
- Only uses AGENTS.md if it contains PONYTAIL marker
- Persona wording: 'less work for the same result' framing
- Anti-hallucination: 'NEVER invent APIs that don't exist' guardrail
- Closes ponytail PR audit tickets #68, #66, #67
- Add find_workspace_agents_md() that walks up from CWD
- Checks each parent directory for AGENTS.md with PONYTAIL marker
- Stops at filesystem root if not found
@getappz
getappz force-pushed the fix/instructions-hardening branch from 61c536e to 7201035 Compare July 7, 2026 17:38
@getappz
getappz merged commit 12505af into master Jul 7, 2026
3 of 4 checks passed
@getappz
getappz deleted the fix/instructions-hardening branch July 7, 2026 17:39
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant