Back to Prompt Library
planning
Define LangGraph State and Initial Agent Nodes
Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.
Linked challenge: Orchestrate Dynamic Content Strategy Agents with LangGraph and OpenAI o4-mini
Format
Code-aware
Lines
7
Sections
1
Linked challenge
Orchestrate Dynamic Content Strategy Agents with LangGraph and OpenAI o4-mini
Prompt source
Original prompt text with formatting preserved for inspection.
7 lines
1 sections
No variables
1 code block
Using LangGraph, define the `AgentState` for a content strategy workflow, including messages, market data, and content drafts. Create initial nodes for a 'MarketAnalyzer' agent and a 'ContentGenerator' agent. The MarketAnalyzer will use OpenAI o4-mini to process incoming market trends, and the ContentGenerator will use Writer for content drafting. Implement a basic graph where the MarketAnalyzer passes its findings to the ContentGenerator. ```python
from typing import TypedDict, Annotated, List
from langgraph.graph import StateGraph, END
from langchain_core.messages import BaseMessage, HumanMessage, AIMessage class AgentState(TypedDict): messages: Annotated[List[BaseMessage], lambda x, y: x + y] # Accumulate messages market_data: str content_draft: str def market_analyzer_node(state: AgentState) -> AgentState: # Use OpenAI o4-mini to analyze state['market_data'] # Simulate analysis for now analysis_result = f"Analysis of market data: {state['market_data']}" return {'messages': [AIMessage(content=analysis_result)], 'market_data': analysis_result} def content_generator_node(state: AgentState) -> AgentState: # Use Writer to generate content based on state['market_data'] # Simulate content generation for now generated_content = f"Content generated based on: {state['market_data']}" return {'messages': [AIMessage(content=generated_content)], 'content_draft': generated_content} workflow = StateGraph(AgentState)
workflow.add_node("market_analyzer", market_analyzer_node)
workflow.add_node("content_generator", content_generator_node) # Your task: Add edges to connect these nodes and define the entry point.
```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 role framing, objective, and reporting structure so comparison runs stay coherent.
Tune next
Swap in your own domain constraints, anomaly thresholds, and examples before you branch variants.
Verify after
Check whether the prompt asks for the right evidence, confidence signal, and escalation path.