π§ Pull Request Creator Agent Specification¶
π― Agent Purpose¶
The Pull Request Creator Agent is responsible for automating the creation of trace-linked, semantically enriched pull requests in Azure DevOps, immediately after a successful code commit by the Code Committer Agent.
It acts as the bridge between automated code generation and human code review, enabling:
- Policy-compliant PR formatting
- Blueprint-aware context population
- Event-driven collaboration
- Release pipeline continuity
This agent ensures that every commit results in a reviewable, auditable, and linkable pull request β connecting architecture, engineering, and DevOps workflows.
π Mission Summary¶
βTransform commit events into complete, traceable pull requests that enable human collaboration, peer review, and automated CI/CD triggers β fully aligned with ConnectSoft traceability and domain-driven principles.β
π§ Strategic Role in Factory Flow¶
| Phase | Role |
|---|---|
| ποΈ Post-Commit Automation | Converts commits into pull requests immediately |
| π Blueprint Traceability | Attaches trace ID, scope, use case to PR metadata |
| π§Ύ Documentation + QA Input | Provides context for doc generation, test cases, release notes |
| π Pipeline Triggering | PRs initiate CI pipelines in Azure DevOps |
| π§βπ€βπ§ Collaboration Entry Point | Enables tech leads, QA, and reviewers to engage in the SDLC |
π§ Key Behaviors Enabled by Purpose¶
| Capability | Enabled Outcome |
|---|---|
| Create PR from feature branch | Ensures GitOps readiness |
| Include commit summary with trace links | Ensures traceability from PR β blueprint |
| Notify Tech Lead or Reviewer Agent | Starts collaborative review |
| Enrich PR with use case, scope, domain, tags | Improves clarity and auditability |
| Enforce PR naming and formatting policies | Aligns with ConnectSoft standards |
π§© Alignment to ConnectSoft Core Principles¶
| Principle | Alignment |
|---|---|
| Clean Architecture | PRs are scoped to single use case or feature |
| Traceability | PRs include trace IDs, blueprint refs, event logs |
| Observability-First | Emits PRCreated events and OTEL spans |
| Security-First | Uses scoped identity or token to create PRs securely |
| Automation by Default | 100% event-driven β no human initiation required |
| Cloud-Native | Operates as a stateless, containerized agent in AKS or MCP |
π§ Summary¶
The Pull Request Creator Agent exists to connect autonomous code commits with human validation and CI/CD orchestration, ensuring every change becomes part of a secure, reviewable, and traceable software delivery flow inside the ConnectSoft factory.
π Core Responsibilities¶
The Pull Request Creator Agent transforms commit metadata into complete, compliant, and traceable pull requests. Its responsibilities span formatting, validation, context enrichment, and lifecycle automation.
β 1. Generate Pull Requests in Azure DevOps¶
- Create PRs between the source (feature/hotfix) and target (main/dev) branches.
- Include enriched metadata: commit hash, component scope, and trace ID.
β 2. Format PR Titles and Descriptions Semantically¶
- PR titles must follow this structure:
β 3. Attach Metadata for Traceability¶
- Inject trace metadata into PR body or description fields:
β 4. Emit PR Lifecycle Events¶
- Emit events such as:
PullRequestCreatedPullRequestFailedPullRequestReadyForReview
- Used by: Tech Lead Agent, Observability Agent, DevOps Orchestrator
β 5. Apply Review and Tag Policies¶
- Assign reviewers (Tech Lead Agent, QA Reviewer)
- Label PRs using tags like:
usecase,domain:<billing>,requires-tests,auto-generated
β 6. Trigger Azure DevOps Pipelines¶
- Optionally auto-create status checks (e.g., lint, tests)
- Trigger CI pipelines via branch push or PR event
β 7. Handle Error and Retry Logic¶
- If PR creation fails (e.g., duplicate PR, Git error):
- Retry with exponential backoff
- If still failing, emit
PullRequestFailedand notifyHumanOpsAgent
β 8. Support Manual or Semi-Automated Review¶
- Mark PR as:
draftif partial contextready-for-reviewif fully traceable
- Supports override from Tech Lead or Reviewer agents
β 9. Store PR Metadata in Long-Term Memory¶
- Map
trace_id β pr_id β commit_hash β branch - Enables audit trail, blueprint retrospectives, and changelog generation
β 10. Ensure Policy Compliance¶
- Validate:
- PR title format
- Mandatory trace and scope fields
- Branch naming convention (
feature/*,hotfix/*)
π§ Summary¶
The Pull Request Creator Agent is responsible for turning autonomous commits into peer-reviewable, trace-complete, policy-compliant pull requests that drive ConnectSoftβs release pipelines and collaborative workflows.
It ensures every software change enters the human validation layer with full context, traceability, and automation awareness.
π₯ Input Overview¶
The Pull Request Creator Agent is triggered automatically by the CommitCompleted event from the Code Committer Agent. It uses this event β along with enriched metadata and lookup sources β to build a complete pull request.
π¬ Primary Inputs¶
β 1. CommitCompleted Event¶
The main trigger and data source.
{
"event": "CommitCompleted",
"trace_id": "trace-ord-8128",
"commit_hash": "9fbc871",
"repo": "OrderService",
"branch": "feature/order-handler",
"agent": "code-committer-agent",
"timestamp": "2025-05-07T19:05:33Z"
}
β 2. Git Commit Metadata¶
Fetched via Azure DevOps Git API or cached memory:
| Field | Use |
|---|---|
commit.message |
Derives PR title |
commit.diff |
File summary for PR body |
commit.author |
Attribution metadata |
commit.tags |
Propagate to PR as labels or comments |
β 3. Trace Metadata¶
Resolved using short- or long-term memory, injected during commit:
{
"trace_id": "trace-ord-8128",
"blueprint_id": "usecase-create-order",
"component_scope": "Order",
"linked_files": [
"src/Application/Handlers/CreateOrderHandler.cs"
]
}
β 4. Branch Naming Policy¶
Loaded from config or Tech Lead Agent:
branch_rules:
allowed_prefixes: [feature/, bugfix/, hotfix/]
target_branch_map:
feature/: dev
hotfix/: main
β 5. PR Template Policy¶
Pulled from ConnectSoft policy memory or repo .pr-template.md:
### Description
${commit_summary}
### Related Trace
- Trace ID: ${trace_id}
- Blueprint: ${blueprint_name}
- Scope: ${component_scope}
### Changed Files
${file_table}
### Checklist
- [x] Code builds
- [x] Blueprint linked
- [ ] Tests attached
β 6. Review Routing Rules¶
Defines who must review based on scope or domain:
β 7. Agent Identity & Auth¶
- Azure DevOps PAT, Managed Identity, or Agent Key
- Required to call PR API and assign reviewers/tags
π§ Summary¶
The Pull Request Creator Agent consumes:
- Commit event signals
- Trace metadata
- Policy templates
- Repo context β¦to generate a fully structured, trace-first pull request that kicks off the next stage of the AI Software Factory pipeline.
π€ Outputs¶
The Pull Request Creator Agent generates structured, traceable outputs that feed into downstream agents, observability pipelines, and human reviewers. These outputs are both Git artifacts and event-based metadata.
π§Ύ Primary Outputs¶
β 1. Pull Request Object (Azure DevOps)¶
Created via the Azure DevOps REST API:
| Field | Example |
|---|---|
title |
feat(order): implement CreateOrderHandler [trace:ord-8128] |
description |
Includes blueprint ID, trace ID, change summary, file table |
source_branch |
feature/order-handler |
target_branch |
dev |
reviewers |
Assigned via rules (TechLeadAgent, QAAssistantAgent) |
labels/tags |
domain:order, traceable, generated-by:AI |
auto_complete |
Optional flag based on team policy |
β
2. Event: PullRequestCreated¶
Emitted to the event bus or MCP server after successful PR creation.
{
"event": "PullRequestCreated",
"pr_id": 3021,
"repo": "OrderService",
"branch": "feature/order-handler",
"trace_id": "trace-ord-8128",
"blueprint_id": "usecase-create-order",
"commit_hash": "9fbc871",
"created_by": "pull-request-creator-agent",
"timestamp": "2025-05-07T20:01:19Z"
}
Used by:
TechLeadAgent(for code review)ObservabilityAgentDevOpsOrchestratorDocumentationAgent
β 3. Human-Readable PR Description (Markdown)¶
Generated from templates:
## Use Case: Create Order
**Trace ID**: trace-ord-8128
**Component**: Order
**Blueprint**: usecase-create-order
### Changes
- β¨ Added: `CreateOrderHandler.cs`
- π§ͺ Added: `CreateOrderHandlerTests.cs`
### Linked Commit
`9fbc871` by `code-committer-agent`
---
β
Ready for review by Tech Lead and QA.
β 4. Review Task Trigger¶
May optionally trigger:
- Review planner agent flow
- Auto-assignment of tasks in DevOps boards or Jira
β 5. OTEL Spans and Logs¶
Logged to observability pipeline:
| Span | Info |
|---|---|
pr.create.start β pr.create.success |
Full timing and status trace |
Tags: trace_id, pr_id, repo, scope |
For searchability and dashboarding |
β 6. Fallback Output (Failure Mode)¶
{
"event": "PullRequestFailed",
"reason": "PR already exists",
"trace_id": "trace-ord-8128",
"attempted_branch": "feature/order-handler",
"created_by": "pull-request-creator-agent",
"timestamp": "2025-05-07T20:03:12Z"
}
Routed to: HumanOpsAgent, DevOpsLeadAgent
π§ Summary¶
The Pull Request Creator Agent outputs a fully initialized Azure DevOps Pull Request, enriched with semantic context, trace metadata, structured markdown, and event signals β enabling downstream automation, observability, and collaboration across the factory.
π Knowledge Base¶
The Pull Request Creator Agent is not a blank-slate LLM call. It operates with a rich preloaded knowledge base, allowing it to consistently produce semantically correct, traceable, and policy-aligned pull requests.
π Knowledge Categories¶
β 1. PR Formatting Templates¶
- Title structure:
<type>(<scope>): <summary> [trace:<id>] - Body templates with sections:
- Use Case / Trace Info
- Changed Files Table
- Commit Metadata
- Review Checklist
Stored as markdown or YAML format in policy config or shared template store.
β 2. Commit β PR Mapping Rules¶
- How to derive PR content from:
- Commit message
- File paths
- Trace ID
- Scope / blueprint
- Includes logic for multi-commit PRs or fallback summaries
β 3. Branch Targeting Policies¶
Defines what target branch to use based on source branch prefix.
β 4. Blueprint and Trace Knowledge¶
Fetched or preloaded from the blueprint registry:
| Field | Description |
|---|---|
trace_id |
Unique per use case |
blueprint_id |
Use case / feature ID |
component_scope |
Domain/module boundary |
description |
Short functional intent |
linked agents |
Origin agents for this feature (e.g., DeveloperAgent) |
Enables PR descriptions to include non-code context like business intent.
β 5. Policy Guidelines¶
Agent understands ConnectSoft-wide standards:
| Area | Rule |
|---|---|
| PR size | Max 3000 LOC changed |
| Commit-to-PR time | < 5 minutes preferred |
| Mandatory reviewers | TechLead, QAAssistant |
| Forbidden keywords | "test", "asdf", "fixme" in PR title |
| Required metadata | trace_id, blueprint_id, repo, branch, scope |
β 6. Labeling and Review Policy¶
Autodetects appropriate PR tags:
| Tag | Trigger |
|---|---|
domain:<X> |
Based on component_scope |
requires-tests |
If new code lacks tests |
generated-by:AI |
Default on all system-created PRs |
automerge-pending |
If pipeline passes and human review is optional |
β 7. Past PR Patterns (Long-Term Memory)¶
- Access to embeddings of previous PRs for similar features
- Enables phrasing alignment, reduces duplicate phrasing, improves clarity
Example: If
CreateUserHandlerPR exists,CreateOrderHandleruses similar description style.
β 8. Azure DevOps API Schema¶
Knows expected fields, statuses, limitations for:
- Creating PRs
- Assigning reviewers
- Attaching tags
- Setting auto-complete and draft flags
π§ Summary¶
The Pull Request Creator Agent operates with an embedded knowledge base covering:
- Templates, patterns, and policies
- Component scope and trace semantics
- Azure DevOps PR mechanics
This makes the agent deterministic, standards-compliant, and safely automatable β without hallucination or formatting drift.
π Process Flow¶
The agent follows an event-driven, trace-first pipeline:
flowchart TD
A[CommitCompleted Event] --> B[Fetch Commit & Trace Metadata]
B --> C[Resolve PR Template & Target Branch]
C --> D[Generate PR Title & Body]
D --> E[Create PR via Azure DevOps API]
E --> F[Assign Reviewers & Labels]
F --> G[Emit PullRequestCreated Event]
G --> H[Notify Observability & Human Agents if needed]
πͺ Detailed Process Steps¶
β
Step 1: Receive CommitCompleted Event¶
- Triggered by Code Committer Agent
- Includes commit hash, branch, trace ID, and repo name
β Step 2: Resolve Commit & Trace Context¶
- Fetch commit message, diff, author from Azure DevOps API
- Resolve
trace_id β blueprint,component_scope,target_branch
β Step 3: Determine PR Template¶
- Load
.pr-template.mdor policy-defined markdown - Resolve variables like:
${trace_id},${scope},${file_table},${commit_summary}
β Step 4: Generate PR Title and Body¶
- Use LLM or SK template planner to generate:
feat(order): implement CreateOrderHandler [trace:ord-8128]
- Format PR body in markdown using trace, blueprint, and commit info
β Step 5: Validate Branch and Target¶
- Check:
- Branch exists?
- Is source branch allowed (
feature/*,bugfix/*)? - Resolve correct merge target (e.g.,
dev,main)
β Step 6: Create Pull Request¶
- Call Azure DevOps REST API:
with structured payload:
* Title, source & target branches
* Description (markdown)
* Auto-complete flag (optional)
β Step 7: Assign Reviewers and Labels¶
- Use policy config or trace-linked routing:
- Add TechLeadAgent, QAAssistant
- Tag:
domain:<X>,generated-by:AI, etc.
β
Step 8: Emit PullRequestCreated Event¶
- Event includes PR ID, repo, trace ID, component scope
- Consumed by:
- Observability Agent
- Documentation Agent
- DevOps Orchestrator
- HumanOpsAgent (if required)
β Error Handling Path¶
- On API failure:
- Retry up to 3 times with exponential backoff
- On persistent failure, emit
PullRequestFailedand notifyHumanOpsAgent
π§ Summary¶
The Pull Request Creator Agentβs process flow is:
- Event-driven (triggered by commit)
- Trace-aware (fully contextualized)
- Template-based (standards compliant)
- Autonomous but recoverable (via retries and human hooks)
It is a critical midpoint between code generation and peer review, linking automation to validation.
π§ Skills & Kernel Functions¶
In the Semantic Kernel ecosystem, skills are modular function collections the agent uses to perform reasoning, transformations, templating, and API orchestration.
The Pull Request Creator Agent combines native SK plugins, ConnectSoft custom skills, and external API wrappers to build and publish traceable PRs.
π§© Core Skills Used¶
β
1. CommitSummarySkill (custom)¶
- Parses one or multiple commits
- Extracts summary per file or module
- Outputs PR body-ready markdown section
Used to populate
Changed Files,Linked Commits, andBlueprint Summary.
β
2. TraceValidationSkill¶
- Confirms trace_id is:
- Valid and linked to blueprint
- Aligned with commit files and scope
- Tags PR as
traceableortrace-violation
β
3. PullRequestTemplateSkill¶
- Uses a reusable markdown template to:
- Generate PR title
- Compose body with dynamic sections (via SK planner)
- Embed metadata (trace ID, commit hash, blueprint)
β
4. AzureDevOpsSkill¶
- Interfaces with Azure DevOps API:
CreatePullRequestAsync(...)AssignReviewer(...)SetAutoComplete(...)AttachLabels(...)
Uses Azure identity or injected PAT for authentication.
β
5. ReviewerPolicySkill¶
- Resolves reviewers dynamically from:
- Component scope
- Blueprint rules
- Org-level domain ownership
β
6. MarkdownFormatterSkill¶
- Formats:
- Diff summaries into tables
- Checklists
- Linked file references
- Trace metadata
β
7. EventEmitterSkill¶
- Emits lifecycle events like:
PullRequestCreatedPullRequestFailedPullRequestReadyForReview
- Event output: JSON over Event Bus / MCP protocol
π€ Example Skill Flow¶
β CommitCompletedEvent
β TraceValidationSkill
β CommitSummarySkill
β ReviewerPolicySkill
β PullRequestTemplateSkill
β AzureDevOpsSkill
β EventEmitterSkill
π§ Skill Composition Mode¶
| Mode | Usage |
|---|---|
| π§© SK Planner | For LLM-guided composition of PR body |
| π SK Pipeline | Sequential execution (validate β generate β push) |
| π§ Embedding Search | Reference past PRs and enforce similarity |
π§ Summary¶
The Pull Request Creator Agentβs intelligence comes from orchestrating a chain of reusable Semantic Kernel skills:
- Validation
- Templating
- DevOps API calls
- Event emission
This enables it to remain modular, extensible, and deterministic, while producing deeply contextual pull requests across all ConnectSoft repositories.
π§° Core Technology Stack¶
The Pull Request Creator Agent is implemented as a cloud-native, event-driven agent leveraging Semantic Kernel, Azure DevOps APIs, and ConnectSoft observability pipelines.
π§ 1. Semantic Kernel (SK)¶
| Feature | Use |
|---|---|
| Planner | Generates PR titles and descriptions using context-driven prompt templates |
| Memory Store | Retains PR template embeddings, trace mappings |
| Skills | Modular plugin system for commit summary, PR formatting, DevOps API calls |
π€ 2. OpenAI (GPT-4 / GPT-4 Turbo)¶
| Use Case | Detail |
|---|---|
| PR body templating | Converts trace + commit + blueprint metadata into human-readable PR description |
| Commit summarization | Auto-generates feature descriptions from diffs |
| Tone tuning | Applies formal, professional tone across descriptions and summaries |
π 3. Azure DevOps REST API¶
| Endpoint | Purpose |
|---|---|
POST /pullrequests |
Create the PR |
PATCH /pullrequests/{id} |
Update title, description, labels |
POST /reviewers |
Assign code reviewers |
POST /labels |
Attach traceability and domain labels |
GET /commits/{id} |
Fetch commit metadata |
Uses Azure AD-managed identity, service principal, or PAT.
π 4. MCP Server (Model Context Protocol)¶
| Feature | Purpose |
|---|---|
| Event relay | Emits PullRequestCreated, PullRequestFailed events |
| Agent discovery | Connects with TechLeadAgent, DevOpsAgent, and ObservabilityAgent |
| Contextual inputs | Supplies blueprint and trace memory lookups via shared context protocol |
π§ 5. Vector Memory Store (e.g., Qdrant, Azure Cognitive Search)¶
| Purpose | |
|---|---|
| Embedding-based lookup | Similar PRs, trace-context embeddings |
| PR style reuse | Ensures consistency in wording and formatting |
| Blueprint β PR linking | Fast retrieval of PR history for a trace ID |
π 6. Observability Stack¶
| Tool | Use |
|---|---|
| OpenTelemetry (OTEL) | Exports spans: PR created, failed, assigned, reviewed |
| Grafana / Application Insights | Dashboards for agent health, PR generation success rate |
| Structured JSON Logs | Captured in blob or log stream per agent run |
βοΈ 7. ConnectSoft Config & Policy Platform¶
| Type | Example |
|---|---|
.pr-template.md |
Rich PR markdown with injected variables |
commit-policy.yaml |
Acceptable branches, message formats, label rules |
review-policy.yaml |
Default reviewers per component scope |
Centralized in ConnectSoft tenant-level configuration layer.
π§ͺ Runtime Environment¶
| Aspect | Technology |
|---|---|
| Language | .NET 8 (C#) |
| Agent Runtime | Azure Container Apps or AKS (Kubernetes) |
| Identity/Auth | Managed Identity or DevOps PAT |
| CI/CD | Deployed via GitHub Actions or Azure DevOps Pipelines |
| Secrets | Azure Key Vault for API tokens, PATs, identities |
π§ Summary¶
The Pull Request Creator Agent combines:
- AI power (OpenAI + SK)
- Enterprise-grade DevOps APIs
- Cloud-native scalability (Azure)
- Event-driven orchestration (MCP)
β¦to deliver a fully autonomous, secure, and standards-aligned PR automation agent for the ConnectSoft AI Software Factory.
π System Prompt¶
The System Prompt is the initial instruction given to the agentβs LLM-driven kernel (e.g., GPT-4 via Semantic Kernel) that sets its role, boundaries, formatting style, compliance requirements, and tone.
It acts as the βrole contractβ for the agent across all pull request generation tasks.
π§ Pull Request Creator Agent β System Prompt¶
You are the Pull Request Creator Agent in the ConnectSoft AI Software Factory.
Your mission is to generate complete, traceable, and policy-compliant pull requests in Azure DevOps based on input from the Code Committer Agent and ConnectSoft trace metadata.
You always follow these rules:
1. PRs must reflect the use case, trace ID, and component scope in the title and body.
2. All PRs are linked to a single traceable change. Never group unrelated commits.
3. PR titles follow this format:
<type>(<component_scope>): <short summary> [trace:<trace_id>]
4. PR body must include:
- Blueprint ID and description
- Changed files summary
- Linked commits
- Review checklist
- Trace metadata block (for automation)
5. Use a formal and informative tone β avoid vague language or internal jargon.
6. If any required data is missing (trace, branch, diff), halt and request correction.
Your output must always be deterministic, standards-aligned, and markdown-formatted.
Do not generate code or modify files β your job is metadata synthesis and PR automation.
π Key Behavior Definitions¶
| Behavior | Instruction |
|---|---|
| π― Focus | Create PRs, not code |
| π Context-Driven | Use trace ID, blueprint, diff to explain purpose |
| βοΈ Language Style | Formal, precise, and consistent across all PRs |
| β Compliance | Enforce traceability and branch policy alignment |
| π« Restrictions | Never invent commits, rewrite code, or bypass trace checks |
π§ System Prompt Effects¶
| Benefit | Outcome |
|---|---|
| π Determinism | Consistent formatting and tone across agents and services |
| π― Scope Control | Prevents hallucinations or unrelated output |
| π§© Seamless Integration | Output plugs directly into DevOps and review workflows |
| π Observability | Trace and scope metadata embedded for analytics and pipelines |
π§ Summary¶
The System Prompt acts as the Pull Request Creator Agentβs governing contract β enforcing trace integrity, formatting standards, and review readiness across every generated PR in the ConnectSoft pipeline.
It ensures every PR:
- Speaks clearly,
- Aligns with trace,
- And invites safe human collaboration.
π§Ύ Input Prompt Template¶
This is the parameterized prompt sent to the LLM (via Semantic Kernel) to generate:
- PR title
- PR description (markdown)
- Embedded metadata block
Itβs populated dynamically with context from:
- Commits
- Trace metadata
- Blueprint registry
- Branching policies
π§ Template Format¶
You are generating a pull request for a software factory-generated feature.
Please create:
- A concise PR title using semantic commit format.
- A detailed PR body in markdown.
- A checklist for reviewers.
- A metadata block for automation systems.
Use the following structured input:
Trace ID: {{trace_id}}
Blueprint ID: {{blueprint_id}}
Blueprint Name: {{blueprint_name}}
Component Scope: {{component_scope}}
Repository: {{repo_name}}
Source Branch: {{branch_name}}
Target Branch: {{target_branch}}
Commit Message: {{commit_message}}
Changed Files:
{{changed_files_list}}
You must:
- Mention the purpose of the feature
- List files added or modified
- Include linked commit hash
- Always include trace_id and component_scope
- Use formal and clear markdown
Begin with PR title. Then provide markdown body.
π§© Variable Placeholders¶
| Variable | Description |
|---|---|
{{trace_id}} |
Required for traceability |
{{blueprint_id}} |
Used in PR body summary |
{{component_scope}} |
Maps to domain context, reviewer assignment |
{{branch_name}} |
Source branch of PR |
{{commit_message}} |
Used to seed PR title and context |
{{changed_files_list}} |
Rendered as table in markdown |
{{repo_name}} |
Used to link artifacts and scope reviewers |
π Example Populated Prompt (Condensed)¶
Trace ID: trace-ord-8128
Blueprint: usecase-create-order
Scope: Order
Repo: OrderService
Source: feature/order-handler
Commit: "feat(order): implement CreateOrderHandler [trace:ord-8128]"
Files:
- src/Application/Handlers/CreateOrderHandler.cs
- tests/Order/CreateOrderHandlerTests.cs
π― Expected Response Structure¶
Title:
feat(order): implement CreateOrderHandler [trace:ord-8128]
Body:
## Summary
Implements order creation handler aligned with blueprint `usecase-create-order`.
## Changed Files
| Path | Type |
|------|------|
| src/Application/Handlers/CreateOrderHandler.cs | New |
| tests/Order/CreateOrderHandlerTests.cs | New |
## Metadata
- Trace ID: trace-ord-8128
- Scope: Order
- Blueprint: usecase-create-order
- Commit: 9fbc871
π§ Summary¶
The Input Prompt Template ensures the agent has a consistent, structured way to turn execution context into a clear, traceable, review-ready pull request. It connects commit intent with factory logic, enabling explainable and policy-aligned outputs.
π€ Output Expectations¶
These define the structure, completeness, and formatting standards for what the agent must emit:
- To Azure DevOps
- To downstream agents (as events)
- And for human review
β 1. Pull Request Title Format¶
The title must follow semantic commit format, scoped and trace-linked:
Example:
| Rule | Reason |
|---|---|
type |
Aligns with commit taxonomy (feat, fix, refactor, etc.) |
component_scope |
Maps to domain or microservice |
trace_id |
Required for traceability and blueprint linkage |
β 2. Pull Request Body Format¶
The body must be in GitHub-Flavored Markdown, structured into sections:
## Summary
Implements the CreateOrderHandler feature as defined in blueprint `usecase-create-order`.
## Blueprint
- Blueprint ID: usecase-create-order
- Component Scope: Order
- Trace ID: trace-ord-8128
## Changed Files
| File | Type |
|------|------|
| src/Application/Handlers/CreateOrderHandler.cs | Added |
| tests/Order/CreateOrderHandlerTests.cs | Added |
## Linked Commit
`9fbc871`
## Review Checklist
- [x] Code builds and compiles
- [x] Trace metadata attached
- [x] Includes unit tests
β
3. Event Output Format (PullRequestCreated)¶
{
"event": "PullRequestCreated",
"pr_id": 3123,
"repo": "OrderService",
"branch": "feature/order-handler",
"trace_id": "trace-ord-8128",
"blueprint_id": "usecase-create-order",
"commit_hash": "9fbc871",
"created_by": "pull-request-creator-agent",
"timestamp": "2025-05-07T21:30:00Z"
}
This event must:
- Be emitted once
- Be consumed by:
TechLeadAgent,ObservabilityAgent,DevOpsAgent,HumanOpsAgent
β 4. PR Metadata Requirements¶
| Field | Required | Description |
|---|---|---|
trace_id |
β | Must be attached and visible |
blueprint_id |
β | Included in PR body |
component_scope |
β | Used to tag and route |
commit_hash |
β | Displayed in metadata section |
reviewers |
β | Assigned via policy rules |
labels |
β | Includes domain:*, traceable, generated-by:AI |
β 5. Tone and Style¶
| Criterion | Standard |
|---|---|
| Language | Formal, precise, business-aligned |
| No filler | No "this is auto-generated" or vague text |
| Markdown | Proper headings, bullet lists, tables |
| Line length | Optimized for readability (max 100 chars/line for description) |
β 6. Observability Metadata¶
Each PR generation must include OpenTelemetry span with:
| Tag | Value |
|---|---|
trace_id |
Required |
repo |
Repository name |
branch |
Source branch |
status |
success, failed, skipped |
agent |
pull-request-creator-agent |
duration_ms |
Execution time |
π§ Summary¶
The Pull Request Creator Agentβs outputs must be:
- Structured (markdown, JSON)
- Traceable (with embedded trace metadata)
- Compliant (matching policy rules)
- Human-readable (review-ready)
- Automation-ready (for event pipelines)
This ensures that every PR serves as both a collaboration artifact and a reliable automation trigger.
π§ Memory Overview¶
The Pull Request Creator Agent maintains dual memory layers:
- π§© Short-Term Memory: In-memory context during a single run
- π§ Long-Term Memory: Persistent store (vector DB, key-value store) for trace mapping, PR history, and blueprint linkage
π 1. Short-Term Memory (In-Memory / Execution Context)¶
| Key | Description |
|---|---|
commit_hash |
Used to generate PR title and metadata |
branch_name |
Used to determine PR source and target |
trace_id |
Passed from upstream agent |
blueprint_id |
Used in PR body and trace metadata |
component_scope |
Determines review routing and labels |
repo |
Needed for DevOps API calls |
diff_summary |
Used for generating Changed Files table |
generated_pr_title |
Temporary result from templating step |
Reset after each run. Stored in SK context and passed across skill steps.
πΎ 2. Long-Term Memory (Persistent Memory Store)¶
β a. Trace β PR Mapping¶
| Key | Value |
|---|---|
trace_id |
β pr_id, commit_hash, branch, repo, blueprint_id |
Enables audits, traceability validation, changelog generation.
β b. Blueprint & Scope Embeddings¶
- Vector store embedding for each blueprint:
- Name, purpose, tags, component, examples
- Enables similar PR detection or phrasing reuse
Example:
usecase-create-orderβ embedding vector used for consistent phrasing across PRs.
β c. PR Template Memory¶
- Markdown structure of
.pr-template.md - Stored as embedding to match future blueprint PRs to preferred layout
β d. Commit Context Archive (Optional)¶
- Stores summaries of recent commits per repo:
- Used for similarity validation
- Detects accidental duplication or repeated effort
β e. Policy Memory¶
Cached copy of:
- Branch naming policies
- Reviewer routing policies
- PR formatting guidelines
- Tokenized commit taxonomy
Loaded at runtime or accessed from shared policy memory agent
π Memory Technologies Used¶
| Memory Type | Backing Store |
|---|---|
| Execution Memory | Semantic Kernel Planner Context |
| Vector Search | Qdrant or Azure AI Search |
| KV Store | Redis or Azure App Configuration |
| Persistent Store | Azure Cosmos DB or Azure Table Storage |
| Blob Archive (optional) | PR markdown copies, JSON logs |
π§ Summary¶
The Pull Request Creator Agentβs memory system provides:
- Short-term execution continuity
- Long-term traceability and context reuse
- Policy-aware, blueprint-linked consistency
- Auditable commit-to-PR chains
This makes the agent stateful in purpose, even when stateless in execution β ideal for scalable, autonomous DevOps flows.
β Validation¶
Validation ensures that each PR created:
- Is traceable to a single blueprint
- Follows ConnectSoft formatting standards
- Complies with branching and review policies
- Is complete and reviewable by downstream agents and humans
π§ͺ Validation Pipeline¶
Validation is applied at multiple stages in the process:
flowchart TD
A[Receive CommitCompleted Event]
--> B[Validate Required Fields]
--> C[Check Trace Integrity]
--> D[Verify Branch Policy]
--> E[Validate Title & Body]
--> F[Confirm Review & Label Policy]
--> G{Pass All Checks?}
G -- No --> H[Abort & Emit PullRequestFailed]
G -- Yes --> I[Proceed to Create PR]
π Validation Dimensions¶
β 1. Required Metadata¶
| Field | Validation |
|---|---|
trace_id |
Must be present and resolvable to a blueprint |
blueprint_id |
Must match trace_id and commit context |
component_scope |
Required for review and label routing |
commit_hash |
Must be non-empty and exist in repo |
repo |
Must be known to the agent with API access |
β 2. Trace Linkage¶
- Validate that:
- Files changed are relevant to declared
component_scope - The
trace_idbelongs to a blueprint linked to that component
- Files changed are relevant to declared
- If mismatch detected β mark as
trace_violation, emit error
β 3. Branch Policy¶
- Source branch must follow allowed prefixes (
feature/,hotfix/, etc.) - Target branch must match policy map (
feature β dev,hotfix β main) - Forbidden branches (e.g.,
master,deprecated/) are rejected
β 4. PR Title and Body Compliance¶
| Check | Rule |
|---|---|
| Title format | Must follow: <type>(<scope>): <summary> [trace:<id>] |
| Markdown structure | Body must include: Summary, Blueprint, Changed Files, Checklist |
| Length limits | Title β€ 100 chars, body β€ 4000 chars |
β 5. Review & Label Policy¶
| Requirement | Validation |
|---|---|
| Reviewers assigned | Must include TechLeadAgent and QA if applicable |
| Labels added | At least: domain:*, traceable, generated-by:AI |
| Auto-merge flag | Disabled if any checklist item is incomplete |
β 6. Dry Run (Optional Preflight Check)¶
When flagged for dry run:
- Validate all above
- Generate and log PR preview
- Do not push to Azure DevOps
- Useful for preflight testing and human inspection
β Validation Failure Response¶
If validation fails:
- PR creation is aborted
- A structured
PullRequestFailedevent is emitted:
{
"event": "PullRequestFailed",
"reason": "trace_violation",
"trace_id": "trace-ord-8128",
"branch": "feature/order-handler",
"repo": "OrderService",
"timestamp": "2025-05-07T22:14:32Z"
}
- HumanOpsAgent or TechLeadAgent is notified for manual review
π§ Summary¶
Validation makes the Pull Request Creator Agent a first-class governance actor:
- It acts not just as a creator, but as a gatekeeper.
- It guarantees correctness, compliance, and trace continuity.
- It prevents polluted PRs, broken automation, or unreviewable code from entering the flow.
π Retry & Correction Flow¶
Autonomous systems must be resilient to:
- Transient failures (e.g., Azure DevOps API timeouts)
- Partial data issues (e.g., missing trace metadata)
- Policy violations (e.g., incorrect branch name)
This agent includes a graceful fallback mechanism with:
- Automatic retries
- Error categorization
- Event emission
- Human escalation
πͺ Retry Strategy¶
β Transient Failure Categories¶
| Error Type | Retry? | Strategy |
|---|---|---|
| Azure DevOps 500 / 429 | β | 3 retries, exponential backoff |
| Network timeout | β | 3 retries, increasing delay (1s β 4s) |
| Rate-limiting | β | Honor Retry-After header or backoff policy |
π« Non-Retryable Errors¶
| Error | Action |
|---|---|
| Invalid trace ID | Abort, emit PullRequestFailed |
| Blueprint mismatch | Emit violation, notify HumanOpsAgent |
| Branch name policy fail | Halt and request human override |
| PR already exists | Skip creation, notify with warning |
π Retry Policy¶
retry_policy:
max_attempts: 3
backoff: exponential
base_delay_ms: 1000
retryable_status_codes: [429, 500, 502, 503]
Retry context is stored in in-memory execution state.
π£ Correction & Escalation Flow¶
If retries fail:
- Emit
PullRequestFailedwith reason code - Notify:
HumanOpsAgentTechLeadAgent(if scope-mapped)
- Log failed PR preview in blob or observability trace
- Set retryable = false to avoid loops
π Example Failure Event¶
{
"event": "PullRequestFailed",
"reason": "azure_devops_500",
"attempts": 3,
"trace_id": "trace-ord-8128",
"repo": "OrderService",
"branch": "feature/order-handler",
"timestamp": "2025-05-07T22:20:55Z"
}
π§ Manual Correction Options¶
| Actor | Action |
|---|---|
| TechLeadAgent | May override PR creation manually |
| HumanOpsAgent | Can requeue the PR with corrected metadata |
| RetryServiceAgent | (optional) may scan failed PRs and re-attempt batch repair nightly |
π§ Summary¶
The Retry & Correction Flow guarantees:
- Resiliency against transient issues
- Safety against non-retryable violations
- Visibility through structured failure events
- Recovery through agent-assisted and human-assisted correction
It ensures the PR creation flow is fail-safe, not fail-silent.
π€ Collaboration Interfaces¶
The Pull Request Creator Agent is a mid-pipeline coordination hub, interfacing with both upstream and downstream agents to facilitate traceable, reviewable code delivery.
π₯ Receives Input From:¶
| Source Agent | Interface | Purpose |
|---|---|---|
| Code Committer Agent | CommitCompleted event |
Triggers the PR generation process |
| Tech Lead Agent | Policy and override context | PR routing, reviewer assignment, manual interventions |
| Trace Agent (optional) | Blueprint enrichment | Provides blueprint summaries and tags if not cached |
π€ Sends Output To:¶
| Target Agent | Interface | Purpose |
|---|---|---|
| Tech Lead Agent | PullRequestCreated event + webhook |
Signals new PR for review |
| Documentation Agent | Trace & commit metadata | Enables blueprint-based doc scaffolding |
| Observability Agent | OTEL spans + structured logs | Traceable telemetry for dashboards and audits |
| DevOps Agent | Event + branch metadata | Triggers CI pipeline based on PR branch |
| HumanOps Agent | PullRequestFailed event |
For intervention on retries or trace violations |
π API & Event Interfaces¶
| Integration | Protocol | Use |
|---|---|---|
| Azure DevOps API | REST over HTTPS | Create PR, assign reviewers, set auto-complete, apply labels |
| MCP Event Bus | JSON-over-message queue | Emit lifecycle events (PullRequestCreated, Failed, ReadyForReview) |
| ConnectSoft Memory Service | HTTP/gRPC | Fetch trace-to-blueprint metadata |
| Shared VFS | File reference or blob path | Used when commits link to large documentation or design files |
| Policy Memory Interface | gRPC or REST | Review, label, and formatting policies per tenant/component |
π§ Semantic Kernel Context Passing¶
The agent participates in an SK-based planning tree, enabling:
- Reuse of generated summaries from previous agents
- Shared embeddings for trace blueprints
- Continuity of execution plan (e.g., commit β PR β release β changelog)
π¬ Collaboration Pattern Summary¶
sequenceDiagram
participant Committer
participant PRCreator
participant DevOps
participant TechLead
participant Observability
Committer->>PRCreator: CommitCompleted Event
PRCreator->>DevOps: Trigger CI (PR created)
PRCreator->>TechLead: Notify for Review
PRCreator->>Observability: Emit OTEL Span
π§ Summary¶
The Pull Request Creator Agent is a collaborative orchestrator that:
- Receives contextual input from engineering agents
- Publishes actionable artifacts to DevOps, docs, and human reviewers
- Integrates into event-driven, trace-first, and observability-enriched workflows
It ensures seamless propagation of traceable changes across the software factory pipeline.
π Observability Hooks¶
The agent provides full visibility into its execution via structured logging, OpenTelemetry spans, and event emission. This enables monitoring, alerting, auditing, and retrospective analysis.
β 1. OpenTelemetry Spans¶
| Span Name | Description |
|---|---|
prcreator.start |
Start of PR creation workflow |
prcreator.template.resolve |
Template assembly and variable injection |
prcreator.title.body.generated |
Output from LLM / SK |
prcreator.devops.api.request |
Azure DevOps PR API call |
prcreator.complete |
Final success/failure |
Common Span Tags:¶
trace_idrepobranchcomponent_scopestatus(success, failed, skipped)error_type(e.g., api_429, missing_trace)
β 2. Structured Logs (JSON)¶
Each run logs:
{
"agent": "pull-request-creator-agent",
"execution_id": "exec-901",
"trace_id": "trace-ord-8128",
"repo": "OrderService",
"branch": "feature/order-handler",
"status": "success",
"pr_id": 3123,
"duration_ms": 2350,
"timestamp": "2025-05-07T22:35:21Z"
}
Captured in:
- Azure Log Analytics
- Blob store archive (optional)
- ConnectSoft Audit Trail service
β 3. Lifecycle Events¶
| Event | Trigger |
|---|---|
PullRequestCreated |
Successful PR |
PullRequestFailed |
Retry exceeded or policy violation |
PullRequestReadyForReview |
When checklist conditions are satisfied |
These events are consumed by:
- TechLeadAgent
- ObservabilityAgent
- HumanOpsAgent
- CI/CD orchestrators
π§βπΌ Human Intervention Hooks¶
When agent automation cannot proceed safely, it gracefully escalates via structured interfaces.
π¨ Escalation Scenarios¶
| Condition | Escalation |
|---|---|
| API fails after 3 retries | Emit PullRequestFailed, notify HumanOpsAgent |
| Invalid trace or branch policy | Route error to TechLeadAgent |
| Title or body format invalid | Create dry-run preview, halt full creation |
| Missing blueprint description | Prompt human or DocAgent to enrich before retry |
π οΈ Manual Tools¶
| Tool | Use |
|---|---|
| PR Preview Viewer (UI) | Review failed/draft PRs before pushing |
| Requeue Interface | Allow human to retry with fixed input |
| Slack / Email Alerts | Notify tech leads or reviewers on failure or review assignment |
| MCP Dashboard | Visualize agent runs, failure reasons, retry actions |
π§ Example: Human Intervention Flow¶
sequenceDiagram
participant PRCreator
participant DevOpsAPI
participant HumanOps
PRCreator->>DevOpsAPI: Create PR (fails 3x)
PRCreator-->>HumanOps: Emit PullRequestFailed
HumanOps->>PRCreator: Retry with override
PRCreator->>DevOpsAPI: Create PR (manual requeue)
π§ Summary¶
The Pull Request Creator Agent is:
-
π Observable by design (Spans, logs, and metrics available at every step)
-
π§© Collaborative by default (Emits events for agents and human interfaces)
-
π‘ Recoverable under failure (Retry logic, human override, preview-before-push)
It maintains factory-grade reliability and traceability, empowering both autonomous execution and human-aware workflows.