Back to Prompt Library
testing

Orchestrate LangGraph Workflow and Evaluate

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: MCP Server for Enterprise Sustainability Reporting

Format
Code-aware
Lines
26
Sections
6
Linked challenge
MCP Server for Enterprise Sustainability Reporting

Prompt source

Original prompt text with formatting preserved for inspection.

26 lines
6 sections
No variables
1 code block
Wire together all your LangGraph nodes (DataReader, DataAnalyzer, RiskAssessor, ReportGenerator) into a cohesive workflow. Define the conditional edges to guide the flow (e.g., if risks are high, branch to a 'HumanReview' node). Instantiate and run your graph with a sample input, ensuring it produces the required JSON output for evaluation.

```python
# Build the LangGraph
workflow = StateGraph(AgentState)
workflow.add_node("data_reader", mcp_data_reader_node)
workflow.add_node("data_analyzer", data_analyzer_node)
workflow.add_node("risk_assessor", lambda state: {"risks": ["Water usage high"], "compliance_status": "FAIL"})
workflow.add_node("report_generator", report_generator_node)

workflow.set_entry_point("data_reader")
workflow.add_edge("data_reader", "data_analyzer")
workflow.add_edge("data_analyzer", "risk_assessor")
workflow.add_edge("risk_assessor", "report_generator")
workflow.add_edge("report_generator", END)

app = workflow.compile()

# Test with a sample input
initial_state = {
    "data_access_request": {"mcp_token": "valid_token_123", "data_sources": []},
    "sustainability_policies": ["Max water usage: 1000m3/month per factory"],
    "reporting_period": "Q1 2024",
    "messages": []
}
final_state = app.invoke(initial_state)

# Print the final state to inspect the generated report
import json
print(json.dumps(final_state['compliance_report'], indent=2))
```

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Preserve the rubric, target behavior, and pass-fail criteria as the baseline for evaluation.

Tune next

Adjust fixtures, mocks, and thresholds to the system under test instead of weakening the assertions.

Verify after

Make sure the prompt catches regressions instead of just mirroring the happy-path examples.