Skip to content

feat(mcp): layer team and project instructions over workspace guidance - #530

Closed
Pallavikumarimdb wants to merge 1 commit into
Noveum:mainfrom
Pallavikumarimdb:feat/layered-agent-instructions
Closed

Pallavikumarimdb wants to merge 1 commit into
Noveum:mainfrom
Pallavikumarimdb:feat/layered-agent-instructions

Conversation

@Pallavikumarimdb

@Pallavikumarimdb Pallavikumarimdb commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Current integration continues in #568, preserving this PR's contribution history. The replacement fixes untouched stale instruction overwrites, uses the explicit OAuth Agent identity, and replaces the conflicting independent 0030 migration with append-only 0038 after #564, #562, #565, #566 and provider #567. This original head remains unchanged until its replacement merges.

Use #568 for current source, validation, dependency and rollout status. Its final combined full verification and staged prerequisites remain pending. The original description below is historical and is not an operational release instruction.


What this changes

Adds configurable agent instructions to teams and projects, layers them under Markdown headings (## Workspace, ## Team, ## Project) in get_workspace_instructions, and automatically attaches resolved instructions in get_issue responses when called by an agent principal.

Why

Teams and projects have distinct conventions such as branch naming rules, definitions of done, and labeling guidelines. Agents executing work in a team or project context need layered instructions that extend workspace-level guidance.

Closes #409

How you know it works

  • Added validation test cases in packages/shared/tests/validators/validators.test.ts covering length constraints up to 4000 characters.
  • Added database persistence tests in packages/core/tests/org/team-service.test.ts and packages/core/tests/work/project-service.test.ts.
  • Added unit tests in packages/mcp-server/tests/instructions.test.ts covering Markdown heading composition, whitespace trimming, and omission of empty layers.
  • Verified MCP tools:
    • get_workspace_instructions without parameters preserves verbatim workspace guidance for backward compatibility.
    • get_workspace_instructions with team/project resolves and layers Markdown headings.
    • get_issue returns resolved instructions when principal.isAgent === true and omits them for human callers.
  • All checks pass: biome check ., check-comments, check-bytes, check-bun-imports, check-deps, typecheck, and db:check-drift.

Checklist

  • bun run verify is green, all four checks
  • Tests added or updated, and they fail without the change
  • No comments added to code, and no em-dash characters anywhere
  • No any, no non-null assertions
  • External input is parsed with a Zod schema from @orbit/shared
  • Authorization is enforced on the server through packages/shared/src/policy, not only in the UI
  • Docs updated if behaviour, configuration or setup changed
  • bun run db:release and bun run db:check-drift passed against the target database before this ships

Anything reviewers should know

  • Backward compatibility: Calling get_workspace_instructions without specifying team or project arguments retains the existing behavior and returns the raw workspace agentInstructions verbatim without heading prefixes.
  • Agent detection: The isAgent property is sourced from schema.member.isAgent and exposed on Principal so get_issue only evaluates and returns instructions for agent principals, preserving compact payloads for human callers.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions github-actions Bot added documentation Docs, the README, or anything that explains Orbit tests Test coverage and test infrastructure area: web The Next.js app and its UI area: mcp The MCP server, its tools and its OAuth area: database Schema, migrations, queries, seed area: policy Roles, permissions and authorization labels Oct 10, 2026
@Pallavikumarimdb
Pallavikumarimdb force-pushed the feat/layered-agent-instructions branch from a0f95e0 to 2a4773c Compare October 10, 2026 15:41

@imshashank imshashank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The guidance composition and permission boundaries look good: resolved teams/projects use visibility-aware readers, the no-argument workspace response stays compatible, empty layers are omitted, and guidance remains advisory. All 138 existing focused core, MCP, validator, and UI tests pass.

One data-loss issue remains in both settings forms. They send unchanged instructions on unrelated saves, so renaming a project or editing a team description from an older tab overwrites guidance saved by another tab. Workspace guidance already protects this exact case with dirty-field omission and expected-instructions checks. Please carry that protection into the new layers and add a two-tab regression.

body: {
name: draft.name,
summary: draft.summary,
instructions: instructions.trim(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Omit unchanged guidance from unrelated settings saves

This field is sent on every save, including a rename when instructions were untouched. If another tab updated guidance after this form loaded, the rename silently restores the old text. team-settings-panel.tsx:65 has the same newly added unconditional field. I reproduced both payloads against the database. Workspace guidance already omits unchanged instructions and has explicit stale-tab tests, so the new layers lose an established protection for this feature. Track guidance dirtiness and omit it from unrelated PATCHes; mirror the expected-instructions contract for overlapping guidance edits. Add form tests proving a stale rename/description save preserves the newer instructions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This finding remains valid on this original head. The replacement #568 at 2a4ad75 omits untouched guidance on unrelated team/project saves and includes form regressions for those payloads, plus the server conflict contract for overlapping instruction edits. All six application CI jobs pass; its final isolated 42-migration full check is still pending. Keep this original PR unmerged until the reviewed replacement lands, then close it with contributor credit and a traceable link.

@imshashank

Copy link
Copy Markdown
Contributor

@Pallavikumarimdb checking in on this draft, nothing has been pushed since the 13th. The one open item: the project and team settings forms send unchanged instructions on every save. So a rename from an older tab silently restores guidance another tab changed (project-settings-form.tsx:92, and team-settings-panel.tsx:65). Workspace guidance already handles this by omitting unchanged fields and checking the expected instructions. Please carry that over and add a two-tab regression.

@imshashank

Copy link
Copy Markdown
Contributor

@Pallavikumarimdb are you still working on this one? Nothing has changed since my last note on the 21st. If you've moved on, that's totally fine, just let me know and I'll close it for now. It can be reopened any time.

Copy link
Copy Markdown
Contributor

Rechecked unchanged head 2a4773c. The stale instruction overwrite remains in both settings forms, and the independent 0030 migration conflicts with released history. Current integration belongs in #568, including explicit Agent identity, stale-save protection and an append-only migration. Keep this original as contribution history rather than merge it.

Copy link
Copy Markdown
Contributor

The replacement preserving this contribution has now landed in #568, normal squash commit 39af4cf. It resolves the original instruction identity/policy and released-migration-history blockers, with PallaviKumari credited. Canonical full verification passed 7,387 tests with zero failures/skips; all fresh CI and the normal READY schema-guarded preview passed. Production schema is verified through 0041. The feature code is merged and awaits the final production build promotion. Closing this superseded PR while preserving its findings and history. Thank you for the original implementation.

@imshashank imshashank closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: database Schema, migrations, queries, seed area: mcp The MCP server, its tools and its OAuth area: policy Roles, permissions and authorization area: web The Next.js app and its UI documentation Docs, the README, or anything that explains Orbit tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Team and project level agent instructions, layered over the workspace ones

2 participants