Question about Enforcing Strict Markdown Entity Reference Formatting in AI Agent Skills #10
Zak Siddiqui opened 2 days ago

Relates to TOD-9

Don't assume. Ask high-level clarifying questions if needed.

  • Numbered questions (1, 2, 3, etc)
  • Lettered answer options (A, B, C, etc)
  • Include a markdown table that contains the following for each question:
    • Pros and Cons?
    • Your recommendation (including justification)?

After questions have been resolved, create an issue and close this one.

📌 Context & Problem Statement

When the AI agent (TOD) submits work, it frequently fails to format references to issues, pull requests, or builds correctly.

For example, TOD recently generated output like:

pr (path/to/project#123)

Because TOD wrapped the reference in parentheses, downstream parsers misattribute or fail to render the link properly (e.g., misidentifying a pull request as an issue due to the extra syntax).

We need a stronger method within all relevant TOD skills under the ## Markdown entity references section to ensure AI models strictly adhere to the required syntax without adding extra brackets, parentheses, or unwanted punctuation.


🎯 Target Specification

The ## Markdown entity references section in all relevant TOD skills must explicitly define and enforce the following formatting rules:

Write <type> <reference>, where type is issue, pr (or pull request), or build. Use #123 in the same project, path/to/project#123 across projects, or PROJ-123 when the project has a key.

Examples: issue #123, pr path/to/project#123, and build PROJ-123.


🛠️ Implementation Specs

📐 Regex Matrix (3 Entity Types x 2 Reference Styles)

To guarantee compliance, each entity type must match one of six explicit regex patterns (configured with case-insensitivity enabled):

Entity TypeReference StyleTarget Regex PatternValid Examples
1. IssuePath / Same Project^issue (?:[\w.-]+\/)*[\w.-]*#\d+$issue #123
issue path/to/project#123
2. IssueProject Key^issue [a-z][a-z0-9_]*-\d+$issue PROJ-123
3. PRPath / Same Project^(?:pr\|pull request) (?:[\w.-]+\/)*[\w.-]*#\d+$pr #123
pr path/to/project#123
4. PRProject Key^(?:pr\|pull request) [a-z][a-z0-9_]*-\d+$pr PROJ-123
5. BuildPath / Same Project^build (?:[\w.-]+\/)*[\w.-]*#\d+$build #123
build path/to/project#123
6. BuildProject Key^build [a-z][a-z0-9_]*-\d+$build PROJ-123

🚫 Explicit Anti-Patterns (To Add to Skill System Prompts)

Include a negative example table directly in skill prompts so TOD explicitly avoids these formatting errors:

❌ Invalid OutputReason✅ Correct Output
pr (path/to/project#123)Do not wrap reference in parenthesespr path/to/project#123
issue [#123]Do not wrap reference in bracketsissue #123
build: PROJ-123Do not add colons after the entity typebuild PROJ-123
pull request (PROJ-123)Do not wrap key in parenthesespull request PROJ-123

✅ Acceptance Criteria

  •  Section ## Markdown entity references in all relevant TOD skills is updated with the exact specification text and the 6 regex definitions.
  •  Prompts explicitly instruct TOD to avoid wrapping references in parentheses (), brackets [], or using colons :.
  •  Test cases are added to verify TOD generates properly formatted references across issues, PRs, and builds.
  •  Written in a compact form so as to minimize AI token usage: The audience is AI, not human.
  • Service Desk commented 2 days ago

    Context from related work: issue #9 already added a shared ## Markdown entity references section (merged via pr #1). This question looks like a follow-up to make that guidance strict enough that agents stop emitting wrappers such as pr (path/to/project#123). Before creating an implementation issue, please confirm the decisions below.

    1. How should we trade token cost against the proposed regex matrix and anti-pattern tables?

    A. Ship the full 6-regex matrix and anti-pattern table in every skill that authors Markdown
    B. Put the full matrix + anti-patterns only in using-tod; other skills keep a short rule plus a pointer to that section
    C. Keep today's short prose rule; add only compact anti-pattern lines (no regexes in prompts)
    D. Other (please specify)

    OptionProsConsRecommendation
    AStrongest local reinforcement wherever comments are draftedHighest token cost; duplicates across skills; conflicts with the "compact form" acceptance note
    BOne canonical detailed section; less duplication; still available when using-tod is loadedAgents that skip using-tod may only see the short pointerRecommended. issue #9 already made using-tod the shared home for Markdown vs CLI forms. Expand that section compactly, and keep workflow skills short but consistent.
    CLowest token cost; targets the observed failure mode (parentheses / brackets / colons)No explicit machine-oriented patterns in the skill text
    DFlexibility for a different packagingNeeds a concrete alternate

    2. What should "test cases" mean in the acceptance criteria?

    A. Golden valid/invalid examples committed under skills/ (or similar), reviewed in the implementation PR
    B. Automated tests in the tod Go suite that assert skill files still contain required headings/examples
    C. Manual checklist only on the implementation issue (no committed tests)
    D. Other (please specify)

    OptionProsConsRecommendation
    AReviewable fixtures that match how skills are consumedNot a runtime guarantee of model complianceRecommended as the primary form of "tests" for prompt/docs content.
    BCI can catch accidental skill deletions/regressionsBrittle string asserts; still does not prove model complianceOptional add-on if cheap
    CFastest to shipEasy to regress later
    DFlexibilityNeeds detail

    3. Are the regexes documentation-only for agents, or should we add programmatic enforcement?

    A. Documentation-only in skills (same boundary as issue #9: no hard validation/linting of posted Markdown)
    B. Add a tod pre-post check that warns or rejects malformed entity references in comments
    C. Other (please specify)

    OptionProsConsRecommendation
    ASmallest change; matches the prior OD-2910 / issue #9 directionStill advisory — models can ignore skillsRecommended for the follow-up created from this question. Clearer negative examples should address pr (...) style failures.
    BReal enforcement at post timeBroader product/CLI scope; risk of false positives in proseDefer unless A proves insufficient
    CFlexibilityNeeds detail

    4. Which skills are in scope?

    A. Only skills that already have a ## Markdown entity references section (using-tod, submit-issue-work, submit-pull-request-work)
    B. Those plus the inline comment-authoring steps in work-on-issue and work-on-pull-request
    C. All companion skills under skills/
    D. Other (please specify)

    OptionProsConsRecommendation
    ATightest diffComment-drafting steps in work-* skills may keep weaker wording
    BCovers every current path that drafts OneDev Markdown referencesSlightly more files/tokensRecommended. Matches issue #9 acceptance and is where bad pr (...) forms are produced.
    CUniformity across the skill packTouches skills that never author entity references
    DFlexibilityNeeds detail

    Please reply with selections (for example 1B, 2A, 3A, 4B) or alternatives. Once resolved, I will create an implementation issue with the chosen options and close this question.

  • Zak Siddiqui commented 2 days ago
    1. b. Also note that instead of six separate regexes, consider combining regexes in order to ensure compactness. However, do not combine if it can result in additional complexity that ends up using more tokens.
    2. a
    3. b
    4. a
  • Service Desk commented 2 days ago

    Recorded selections: 1B (combine regexes only when more compact / not more complex), 2A, 3B, 4A.

    Created implementation issue #11 with those decisions and linked it as Related. Closing this question.

  • Service Desk changed state to 'Closed' 2 days ago
    Previous Value Current Value
    Open
    Closed
1/1
Type
Question
Priority
Normal
Assignee
Labels
No labels
Issue Votes (0)
Watchers (3)
Reference
TOD-10
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover