Example: Planning with Our Assistant › Handling Complications
Michael BrenndoerferJuly 23, 20251 min read
AI Agent HandbookAll chapters Part 9 of 15Planning - Agents with a Plan
Example: Planning with Our Assistant › Handling ComplicationsOne section · Sections in this chapter6 / 9 ↓
Sections in this chapter9
Real-world scenarios rarely go perfectly. Let's see how our assistant handles a complication.
Suppose when the assistant tries to retrieve Q3 notes, the memory system returns incomplete information:
In[2]:
Code## Example (Claude Sonnet 4.5)
## Simulating incomplete data retrieval
q3_data_incomplete = retrieve_project_notes("marketing", "Q3 2025")
if len(q3_data_incomplete["notes"]) < 3:
# Assistant recognizes insufficient information
replanning_prompt = """
I was asked to summarize Q3 marketing work, but I only found limited notes.
What should I do?
Options:
A) Send what I have
B) Ask the user for more information
C) Search additional sources
D) Indicate in the summary that information is incomplete
Consider: The summary will be sent to Alice before a meeting.
"""
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=256,
messages=[{"role": "user", "content": replanning_prompt}],
)
print(response.content[0].text)A well-designed assistant might respond:
I should ask the user for more information (Option B). Sending incomplete
information to Alice could make us look unprepared for the meeting. I'll
pause execution and request additional details from the user.This demonstrates adaptive planning. When the original plan hits an obstacle, the assistant can recognize the problem and adjust its approach.