Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
123 changes: 123 additions & 0 deletions 3_crew/community_contributions/leadership_calibration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
## Leadership Calibration Crew

Welcome to the **Leadership Calibration** project, powered by [crewAI](https://crewai.com).

This crew models a structured debate between two senior leadership personas:

- **Senior Architect** – focuses on technical design, scalability, and system quality.
- **Engineering Manager** – focuses on people, delivery, and business impact.

Given a topic, the crew runs a multi-step debate and produces:

- **Architect position** → `architect.md`
- **Engineering manager position** → `manager.md`
- **Final synthesized conclusion** → `conclusion.md`

You can run the crew through an interactive Gradio UI.

---

## Installation

- **Python**: requires `>=3.10,<3.14`
- **Dependencies**: managed with [UV](https://docs.astral.sh/uv/) and `pyproject.toml`

Install `uv` (once, globally):

```bash
pip install uv
```

From the project root (`3_crew/leadership_calibration`), install dependencies:

```bash
uv sync
```

Or, if you prefer the crewAI CLI workflow:

```bash
crewai install
```

Make sure your `OPENAI_API_KEY` (or other LLM provider keys) is available in the environment
or defined in a local `.env` file.

---

## Project Structure

Key components of the crew live under `src/leadership_calibration`:

- **Agents configuration**: `config/agents.yaml`
- `engineering_manager_agent` – senior engineering manager & technical leader
- `senior_architect_agent` – senior software engineer & architect

- **Tasks configuration**: `config/tasks.yaml`
- `architect_position_statement` → writes `output/architect.md`
- `engineering_manager_position_statement` → writes `output/manager.md`
- `final_alignment_and_resolution` → writes `output/conclusion.md`

- **Crew orchestration**: `crew.py`
- Defines the `LeadershipCalibration` crew and wires agents + tasks.

- **CLI entrypoints**: `main.py`
- Provides `run`, `train`, `replay`, `test`, and `run_with_trigger` functions.

- **Gradio app**: `app.py`
- Defines a small UI where you can type a topic and watch the debate stream.

Generated outputs are written under an `output/` folder (either in the package or project root,
depending on how you invoke the crew).

---

## Running the Gradio UI

The interactive web UI is defined in `src/leadership_calibration/app.py` using Gradio.
To launch it:

```bash
uv run app.py
```

Then:

1. Open the local URL printed by Gradio in your browser.
2. Enter a **debate topic** (e.g. “Should we migrate to microservices?”).
3. Click **Start Debate** to begin streaming the discussion.
4. Use **Cancel Debate** to stop an in-progress run.

The final markdown output still lands in the `output/` folder and is also shown in the UI.

---

## Customizing the Leadership Calibration

- **Agents** – edit `src/leadership_calibration/config/agents.yaml`
- Update roles, goals, and instructional style (`instructions` block).

- **Tasks & debate flow** – edit `src/leadership_calibration/config/tasks.yaml`
- Change task descriptions, expected outputs, or ordering.

- **Crew wiring & tools** – edit `src/leadership_calibration/crew.py`
- Add or modify tools, change which agent runs which task, or tweak parameters.

- **CLI behavior** – edit `src/leadership_calibration/main.py`
- Adjust default topics, input schema, or logging.

- **UI behavior** – edit `src/leadership_calibration/app.py` and `debate_runner.py`
- Change layout, streaming behavior, or how the debate is rendered.

---

## Support

For more about crewAI:

- **Docs**: `https://docs.crewai.com`
- **GitHub**: `https://github.com/joaomdmoura/crewai`
- **Discord**: `https://discord.com/invite/X4JWnZnxPb`

This project is a specialized example on top of crewAI for calibrating leadership decisions via structured debate.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User name is John Doe.
User is an AI Engineer.
User is interested in AI Agents.
User is based in San Francisco, California.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[project]
name = "leadership_calibration"
version = "0.1.0"
description = "Leadership Calibration using crewAI"
authors = [{ name = "Your Name", email = "you@example.com" }]
requires-python = ">=3.10,<3.14"
dependencies = [
"crewai[tools]==1.8.1",
"gradio>=6.8.0",
]

[project.scripts]
leadership_calibration = "leadership_calibration.main:run"
run_crew = "leadership_calibration.main:run"
train = "leadership_calibration.main:train"
replay = "leadership_calibration.main:replay"
test = "leadership_calibration.main:test"
run_with_trigger = "leadership_calibration.main:run_with_trigger"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.crewai]
type = "crew"
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import gradio as gr
import time
from debate_runner import run_debate, run_debate_stream, cancel_debate


def debate_interface(topic):
if not topic.strip():
return "Please enter a debate topic."

result = run_debate(topic)
return result


def test_debate(topic):
time.sleep(10)
result = f"""**Summary of Both Positions**
The debate surrounding {topic}"""
return result


def handle_button(topic, state, button_label):
# If currently running → cancel
if button_label == "Cancel Debate":
state = cancel_debate(state)
return (
"❌ Cancelling debate...",
state,
gr.update(value="Start Debate", variant="primary")
)

# Otherwise start debate
generator = run_debate_stream(topic, state)

# First update button to Cancel
yield (
"⏳ Starting debate...\n",
state,
gr.update(value="Cancel Debate", variant="stop")
)

# Stream debate
for output, updated_state in generator:
yield (
output,
updated_state,
gr.update(value="Cancel Debate", variant="stop")
)

# When finished → reset button
yield (
output,
updated_state,
gr.update(value="Start Debate", variant="primary")
)


with gr.Blocks() as app:
gr.Markdown("# 🧠 Leadership Calibration Debate Engine")
gr.Markdown("""Enter any topic and watch two Leadership personas (Technical
Architect and Engineering Manager) debate and come up with final
conclusion. \n\n
The Technical Architect is responsible for the technical aspects of the
project. \n\n
The Engineering Manager is responsible for the people aspects of the
project.""")

topic_input = gr.TextArea(
label="Debate Topic",
placeholder="Example: Should companies adopt a 4-day work week?",
lines=5
)

state = gr.State({"cancelled": False})

debate_button = gr.Button("Start Debate", variant="primary")

output = gr.Markdown(visible=True)

debate_button.click(
handle_button,
inputs=[topic_input, state, debate_button],
outputs=[output, state, debate_button]
)

if __name__ == "__main__":
app.queue()
app.launch()
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
engineering_manager_agent:
role: Senior Software Engineering Manager & Technical Leader

goal: >
Lead engineering initiatives aligned with business goals while ensuring
high technical quality, sustainable delivery, and strong team performance.

backstory: >
You are an experienced engineering leader who has managed high-performing
teams in scaling technology organizations. You combine strategic thinking,
technical depth, and people leadership. You have led roadmap planning,
architecture decisions, incident management, hiring, and performance reviews.
You prioritize outcomes over output and sustainability over short-term wins.

verbose: true
allow_delegation: false

instructions: >
When responding:

- Align technical decisions with business priorities.
- Explicitly identify risks, trade-offs, and dependencies.
- Separate strategic direction from tactical steps.
- Promote ownership, accountability, and psychological safety.
- Provide constructive and actionable feedback.
- Evaluate scalability, maintainability, and technical debt.
- Structure complex responses as:
1. Executive Summary
2. Key Risks
3. Recommended Approach
4. Trade-offs
5. Execution Plan
6. Success Metrics
- Ask clarifying questions if requirements are unclear.
- Be decisive, structured, and professional.


senior_architect_agent:
role: Senior Software Engineer & Software Architect

goal: >
Design scalable, resilient, and maintainable systems and deliver
production-grade technical solutions with clearly articulated trade-offs.

backstory: >
You are a highly experienced senior engineer and architect who has built
distributed systems and operated them in production. You specialize in
system design, performance optimization, API design, data modeling,
reliability engineering, and operational excellence. You care deeply
about clean abstractions, failure modes, observability, and long-term maintainability.

verbose: true
allow_delegation: false

instructions: >
When responding:

- Clearly frame the problem and identify assumptions.
- Distinguish functional vs non-functional requirements.
- Define architecture components and boundaries.
- Describe data flow and scalability model.
- Identify bottlenecks and failure modes.
- Evaluate trade-offs (complexity vs scalability vs cost).
- Consider security, observability, deployment, and rollback.
- When producing code, write production-ready solutions.
- Structure complex responses as:
1. Problem Framing
2. Proposed Design
3. Alternatives
4. Risks
5. Recommendation
- Push back on unsafe or fragile designs.
- Prefer simplicity unless complexity is justified.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
architect_position_statement:
description: >
description: >
Topic for debate:
"{topic}"

Provide a structured position from your assigned perspective.
Define assumptions, key arguments, risks, and initial recommendation.

expected_output: >
- Core Assumptions
- Key Arguments
- Risks & Trade-offs
- Initial Conclusion

output_file: output/architect.md
agent: senior_architect_agent


engineering_manager_position_statement:
description: >
Topic for debate:
"{topic}"

Respond to the previous position.
Critique assumptions and provide counterarguments.
Offer alternative framing and recommendations.

expected_output: >
- Agreement / Disagreement
- Counterarguments
- Broader Impact Analysis
- Revised Recommendation

output_file: output/manager.md
agent: engineering_manager_agent

context:
- architect_position_statement


final_alignment_and_resolution:
description: >
Topic for debate:
"{topic}"

Synthesize both perspectives and produce a balanced final resolution.
The resolution should integrate analytical rigor and human-centered reasoning.

expected_output: >
- Summary of Both Positions
- Key Tensions Identified
- Integrated Balanced Resolution
- Contexts Where Each View Dominates
- Final Recommendation

output_file: output/conclusion.md
agent: senior_architect_agent

context:
- architect_position_statement
- engineering_manager_position_statement
Loading