0
0
Agentic AIml~10 mins

LangGraph for stateful agents in Agentic AI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize a LangGraph agent with a state.

Agentic AI
agent = LangGraphAgent(state=[1])
Drag options to blanks, or click blank then click option'
A{}
B0
CNone
D[]
Attempts:
3 left
💡 Hint
Common Mistakes
Using None instead of an empty dictionary causes errors when updating state.
Using a list [] does not allow key-based state storage.
2fill in blank
medium

Complete the code to update the agent's state with a new key-value pair.

Agentic AI
agent.state[[1]] = 'active'
Drag options to blanks, or click blank then click option'
Astatus
B'status'
C'state'
D'mode'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the key causes a NameError.
Using an incorrect key name that doesn't match the intended state.
3fill in blank
hard

Fix the error in the code to retrieve the agent's current mode safely.

Agentic AI
current_mode = agent.state.get([1], 'idle')
Drag options to blanks, or click blank then click option'
Amode
Bstatus
C'state'
D'mode'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted keys causes NameError.
Using wrong key names returns unexpected results.
4fill in blank
hard

Fill both blanks to create a LangGraph agent that updates state and then retrieves a value.

Agentic AI
agent.state[[1]] = 'running'
mode = agent.state.get([2], 'stopped')
Drag options to blanks, or click blank then click option'
A'mode'
B'status'
D'state'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up keys causes wrong state updates or retrievals.
Forgetting quotes around keys causes errors.
5fill in blank
hard

Fill all three blanks to define a function that updates the agent's state and returns the updated value.

Agentic AI
def update_agent_state(agent, key, value):
    agent.state[[1]] = [2]
    return agent.state.get([3])
Drag options to blanks, or click blank then click option'
Akey
Bvalue
D'value'
Attempts:
3 left
💡 Hint
Common Mistakes
Using string literals instead of variables.
Forgetting to return the updated value.