from splinter.workflow import Workflow
from splinter.types import AgentConfig, ExecutionLimits, LLMProvider
# Create workflow
workflow = Workflow(
workflow_id="research-pipeline",
limits=ExecutionLimits(max_budget=20.0, max_steps=200),
checkpoint_enabled=True,
)
# Add agents
workflow.add_agent(AgentConfig(
agent_id="researcher",
provider=LLMProvider.OPENAI,
model="gpt-4o",
system_prompt="Research topics. Output JSON.",
state_ownership=["research.*"],
))
workflow.add_agent(AgentConfig(
agent_id="writer",
provider=LLMProvider.ANTHROPIC,
model="claude-sonnet-4-20250514",
system_prompt="Write articles. Output JSON.",
state_ownership=["content.*"],
))
# Define execution order
workflow.add_step("researcher")
workflow.add_step("writer", depends_on=["researcher"])
# Run
result = await workflow.run(initial_state={"topic": "AI trends"})
print(f"Success: {result.success}")
print(f"Cost: ${result.metrics['total_cost']:.4f}")
print(f"Research: {result.outputs['researcher']}")
print(f"Article: {result.outputs['writer']}")