Bird
0
0

How would you combine the Command pattern with Agent API design to allow undoing actions?

hard📝 Application Q9 of 15
Agentic AI - Production Agent Architecture
How would you combine the Command pattern with Agent API design to allow undoing actions?
AUse a global variable to track last action
BImplement agents as singletons
CSend messages directly without storing state
DEncapsulate requests as objects with execute and undo methods
Step-by-Step Solution
Solution:
  1. Step 1: Recall Command pattern purpose

    Command pattern encapsulates requests as objects, allowing actions to be executed and undone.
  2. Step 2: Apply to Agent API for undo functionality

    Agents can store commands with execute and undo methods to reverse actions when needed.
  3. Final Answer:

    Encapsulate requests as objects with execute and undo methods -> Option D
  4. Quick Check:

    Undo actions require command objects with undo [OK]
Quick Trick: Command pattern supports undo via execute/undo methods [OK]
Common Mistakes:
  • Using global variables which are error-prone
  • Ignoring state storage for undo
  • Confusing singleton with undo functionality

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes