Question: how do OneDev AI agents running in workspaces know how to construct links to issues, PRs, and builds #2910
Zak Siddiqui opened 9 hours ago

Summary

How do OneDev AI agents running in workspaces know how to construct links to issues, PRs, and builds?

Description

When an AI agent operates within a OneDev workspace, it often needs to reference other assets. However, OneDev requires explicit prefixes to prevent conflicts (e.g., writing issue #123, pr #45, or build #67 instead of just #123).

If the agent needs to reference an asset in another project, it must use the cross-project syntax (e.g., path/to/project#issue-123).

Questions

  1. Is this context automatically injected into the agent's system prompt by the OneDev runtime environment?
  2. Does the agent have access to a specific schema or tool definition that enforces this Markdown syntax?
  3. What is the recommended way to train or prompt a custom workspace agent so it never falls back to standard GitHub-style #123 shorthand?

Proposed Soution

The following text should be added by default to the system prompt of every AI user:

Append to System Prompt

Because OneDev tracks issue numbers and PR numbers independently, a standalone "#123" is invalid and causes conflicts. You must always use the explicit prefix format:

- **Issue Reference:** `issue #<number>` (e.g., `issue #45`)
- **PR Reference:** `pr #<number>` (e.g., `pr #12`)
- **Build Reference:** `build #<number>` (e.g., `build #98`)

**Cross-Project References:**
When referencing an asset in a different OneDev project path, use the project path combined with the specific entity type:
- **External Project Issue:** `path/to/project#issue-<number>` (e.g., `my-group/backend#issue-45`)
- **External Project PR:** `path/to/project#pr-<number>` (e.g., `my-group/backend#pr-12`)

Always apply these prefix rules carefully to ensure all links render correctly inside OneDev Markdown fields.

Request

Create this as a new issue and submitted to @robin for approval

  • Service Desk commented 9 hours ago

    Answer

    Short version: OneDev does not auto-inject Markdown reference syntax into the agent system prompt. Agents learn the useful forms mainly from the tod companion skills (and any custom system prompt / project instructions you add).

    1. Is this injected by the OneDev runtime?

    No. For task automation, the runtime builds the prompt roughly as:

    1. A small fixed ### Rules block (e.g. that the agent is talking to an AI user, and to wait for sub-agents)
    2. The AI user's optional system prompt from AI settings (if set)
    3. The ### User task text

    There is no built-in injection of issue #… / pr #… / build #… rules.

    Docs for context: Working with AI User (optional system prompt) and Working with Workspaces (templates ship tod + companion skills).

    2. Is there a schema/tool that enforces the Markdown syntax?

    No enforcing schema or tool. Nothing validates comment text against OneDev reference syntax before posting.

    What does exist:

    • tod companion skills (onedev/tod skills/) teach agents workflow conventions. In particular, work-on-issue / submit-issue-work tell the agent that when a comment mentions a pull request, use the exact form pr #<number>.
    • The using-tod skill documents CLI reference forms (123, #123, project#123, KEY-123). Those are for tod arguments, not a full Markdown linking guide.

    Why prefixes matter (and a correction)

    Issue / PR / build numbers are independent. In Markdown, a bare #123 is still recognized, but it is treated as an issue reference. So for PRs/builds you need an explicit type prefix, e.g. pr #45, build #67 (also pull request #45).

    Cross-project forms use project path or key before the number, with the type prefix in front when needed:

    • Same project: issue #45, pr #12, build #98
    • Other project by path: issue path/to/project#45, pr path/to/project#12
    • Other project by key: issue OD-45, pr OD-12 (or OD-45 for an issue)

    The proposed path/to/project#issue-45 form is not the syntax OneDev parses.

    1. Install tod + companion skills in the agent environment (workspace templates / images already do this; see tod skills README).
    2. For stricter habit-forming, put short reference rules in the AI user's system prompt, and/or in project AGENTS.md / agent rules / a small custom skill—especially: never use bare #N when you mean a PR or build; use pr #N / build #N.
    3. Relying only on a default system-prompt append for every AI user is not how the product works today; that would be a product change rather than current behavior.

    If this answers the question, we can close the issue. If you want the default system-prompt append implemented as a product change, say so and we can follow up.

  • Zak Siddiqui commented 8 hours ago

    @servicedesk I do concede that a default system prompt append for AI users doesn't sound like it would be the best thing to do. It sounds like a workaround fix, and I'm trying to understand if there's a better fix. Would it be better to update the tod skills docs instead?

    My only concern in doing it that way is that I have seen the ai agent not accurately use the TOD syntax. Hence the reason for my call to explicitly append the system prompt during workspace runtime.

    Pros/cons? Your recommendation?

  • Service Desk commented 8 hours ago

    @zaakiy Yes — updating the tod companion skills is the better primary fix. Pros/cons and recommendation below.

    Skills docs vs system-prompt append

    Update tod skillsAppend to AI user system prompt
    ProsShips with workspace/tod installs; loaded when agents run issue/PR workflows; versioned and reviewable; can document Markdown forms separately from CLI refsAlways present every turn for that AI user; may help when a skill isn't loaded or is skimmed
    ConsAdvisory only — models can still ignore skills (matching what you've seen); sparse coverage today (pr #<n> is mentioned in a few workflows, but there's no full Markdown linking section)Token cost on every prompt; applies even when not writing references; still not enforced; a product-wide default append is a product change and feels like a workaround (as you noted)

    Neither approach enforces syntax. Agents that mis-use references can ignore skills and system prompts. Hard guarantees would need validation/linting of posted text (a separate product feature).

    Recommendation

    1. Prefer improving tod skills as the main fix: add a clear Markdown reference section (same-project issue #N / pr #N / build #N, cross-project forms, and “bare #N means issue”) to using-tod, and reinforce it in comment-drafting steps of work-on-issue / submit-issue-work. That targets the real gap — CLI refs are documented; Markdown linking for comments is only lightly covered.

    2. Use an optional system prompt (or project AGENTS.md) only as site-level reinforcement if you still see failures after the skills update — short, high-signal rules, not a long append for every AI user by default.

    3. Do not make a default runtime system-prompt append the primary design; skills + optional local reinforcement is cleaner and matches how agents are already steered today.

    If this recommendation works for you, we can close this question. If you'd like a follow-up to actually expand the tod skills (or explore comment-time validation), say which you prefer.

  • Zak Siddiqui commented 7 hours ago

    @servicedesk please create an issue for option one. Please note that I believe it's not in this project. I believe it should be created in the tod project. https://code.onedev.io/onedev/tod

    CC @robin

  • Service Desk commented 7 hours ago

    @zaakiy Created the follow-up for option one in the tod project: issue onedev/tod#9 (assigned to robin). Linked it as Related to this issue. Closing this question as answered — please continue any discussion there.

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