Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions python/samples/concepts/osop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# OSOP Workflow Examples for Semantic Kernel

[OSOP](https://github.com/osopcloud/osop-spec) (Open Standard for Orchestration Protocols) is a portable YAML format for describing AI workflows — think OpenAPI, but for agent orchestration.

## What's Here

| File | Description |
|------|-------------|
| `code-review-pipeline.osop.yaml` | Automated PR review: fetch diff, parallel analysis (complexity + security + tests), generate review, post comments |

## Why OSOP?

Semantic Kernel provides powerful AI orchestration with plugins, planners, and agents. OSOP provides a **framework-agnostic way to describe** those orchestration patterns so they can be:

- **Documented** — readable YAML that non-developers can understand
- **Validated** — check workflow structure before execution
- **Ported** — same workflow definition works across Semantic Kernel, LangChain, AutoGen, etc.
- **Visualized** — render the workflow as a graph in the [OSOP Editor](https://github.com/osopcloud/osop-editor)

## Quick Start

```bash
# Validate the workflow
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 osop package on PyPI has no author, summary, homepage, or project URLs. Recommending pip install osop in an official Microsoft repo without vetting this package is a trust and supply-chain risk. At minimum, pin to a specific version and verify the package provenance before publishing this.

Suggested change
# Validate the workflow
pip install osop==0.5 # verify package provenance before use

pip install osop
osop validate code-review-pipeline.osop.yaml

# Or just read the YAML — it's self-documenting
cat code-review-pipeline.osop.yaml
```

## How It Maps to Semantic Kernel

| OSOP Concept | Semantic Kernel Equivalent |
|---|---|
| `node` with `type: agent` | `ChatCompletionAgent` / `OpenAIAssistantAgent` |
| `node` with `type: api` | Native function / Plugin |
| `edge` with `mode: parallel` | Parallel plugin execution |
| `edge` with `mode: conditional` | `KernelFunction` with conditional logic |
| `config.plugins` | Semantic Kernel plugins |

## Learn More

- [OSOP Spec](https://github.com/osopcloud/osop-spec) — full specification
- [OSOP Examples](https://github.com/osopcloud/osop-examples) — 30+ workflow templates
- [OSOP Editor](https://github.com/osopcloud/osop-editor) — visual workflow editor
100 changes: 100 additions & 0 deletions python/samples/concepts/osop/code-review-pipeline.osop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Semantic Kernel Automated Code Review — OSOP Portable Workflow
#
# AI-powered PR review: fetch the diff, analyze complexity and patterns
# in parallel, generate a structured review, post comments on GitHub,
# and request changes if critical issues are found.
#
# Run with Semantic Kernel or validate: osop validate semantic-kernel-code-review.osop.yaml
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.

Filename mismatch: the comment references semantic-kernel-code-review.osop.yaml but the actual file is named code-review-pipeline.osop.yaml.

Suggested change
# Run with Semantic Kernel or validate: osop validate semantic-kernel-code-review.osop.yaml
# Run with Semantic Kernel or validate: osop validate code-review-pipeline.osop.yaml

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.

Filename in the comment doesn't match the actual file. Should be code-review-pipeline.osop.yaml.

Suggested change
# Run with Semantic Kernel or validate: osop validate semantic-kernel-code-review.osop.yaml
# Run with Semantic Kernel or validate: osop validate code-review-pipeline.osop.yaml


osop_version: "1.0"
id: "semantic-kernel-code-review"
name: "Automated Code Review"
description: "Fetch PR diff → parallel analysis → generate review → post comments."
version: "1.0.0"
tags: [semantic-kernel, code-review, github, llm, devtools]

nodes:
- id: "fetch_diff"
type: "api"
subtype: "rest"
name: "Fetch PR Diff"
description: "Pull the diff and file list from the GitHub PR API."
config:
url: "https://api.github.com/repos/{owner}/{repo}/pulls/{number}"

- id: "analyze_complexity"
type: "agent"
subtype: "llm"
name: "Analyze Complexity"
description: "Measure cyclomatic complexity, function length, and nesting depth."
config:
model: "gpt-4o"
plugins: [code_analysis]

- id: "check_patterns"
type: "agent"
subtype: "llm"
name: "Check Patterns & Security"
description: "Scan for anti-patterns, SQL injection, hardcoded secrets, and OWASP issues."
config:
model: "gpt-4o"
plugins: [security_scanner, pattern_matcher]

- id: "check_tests"
type: "agent"
subtype: "llm"
name: "Check Test Coverage"
description: "Verify new code paths have corresponding test cases."
Comment on lines +43 to +47
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.

check_tests is the only agent node without a config.model field. All other type: agent nodes specify a model; omitting it here creates an inconsistent and incomplete workflow definition.

Suggested change
- id: "check_tests"
type: "agent"
subtype: "llm"
name: "Check Test Coverage"
description: "Verify new code paths have corresponding test cases."
- id: "check_tests"
type: "agent"
subtype: "llm"
name: "Check Test Coverage"
description: "Verify new code paths have corresponding test cases."
config:
model: "gpt-4o"


- id: "generate_review"
type: "agent"
subtype: "llm"
name: "Generate Review"
description: "Synthesize all analysis into a structured review with severity levels."
config:
output_schema:
summary: "string"
issues: [{ file: "string", line: "int", severity: "string", message: "string" }]
verdict: "approve | request_changes"

- id: "post_comments"
type: "api"
subtype: "rest"
name: "Post Review Comments"
description: "Submit inline comments and overall review via GitHub API."
config:
url: "https://api.github.com/repos/{owner}/{repo}/pulls/{number}/reviews"

- id: "request_changes"
type: "api"
subtype: "rest"
name: "Request Changes"
description: "Mark the PR as 'changes requested' when critical issues are found."

edges:
- from: "fetch_diff"
to: "analyze_complexity"
mode: "parallel"
- from: "fetch_diff"
to: "check_patterns"
mode: "parallel"
- from: "fetch_diff"
to: "check_tests"
mode: "parallel"
- from: "analyze_complexity"
to: "generate_review"
mode: "sequential"
- from: "check_patterns"
to: "generate_review"
mode: "sequential"
- from: "check_tests"
to: "generate_review"
mode: "sequential"
- from: "generate_review"
to: "post_comments"
mode: "sequential"
- from: "generate_review"
to: "request_changes"
mode: "conditional"
when: "verdict == 'request_changes'"
label: "Critical issues found"
Loading