Audit an Agent Procedure Graph for Unreachable and Trapped Steps

Last updated: November 29, 2026

Quick Overview

An agent procedure is a directed graph of steps (each step lists its possible next steps, steps with none are terminal). Given the graph and a start step, return steps that can never be reached, reachable steps from which no terminal step can be reached, and steps that are referenced but never defined.

Decagon
Coding & Algorithms
Software Engineer
Decagon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


An agent procedure is a directed graph of steps (each step lists its possible next steps, steps with none are terminal). Given the graph and a start step, return steps that can never be reached, reachable steps from which no terminal step can be reached, and steps that are referenced but never defined.

Decagon compiles natural-language Agent Operating Procedures into structured logic, so a linter that catches broken branches before a procedure ships is a realistic piece of its tooling. The interviewer checks graph modeling, the reverse-graph trick for 'can reach a terminal', and that you do not wrongly reject legitimate retry loops.

What the Interviewer Expects
  • Models the procedure as a directed graph including referenced-only nodes
  • Uses forward BFS from start for reachability
  • Uses reverse BFS from terminals to find steps that can finish
  • Does not treat every cycle as an error (a retry loop with an exit is fine)
  • Runs in linear time in steps plus edges
Key Topics to Cover
graphs
BFS
reverse graph
reachability
static analysis
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you also report the shortest path from start to each trapped step for the error message?
  • Steps have conditions on their edges and some conditions are mutually exclusive. How does that change the analysis?
  • How would you flag a cycle that has an exit but no step inside it that changes state?
  • How would you run this check in CI whenever a procedure is edited?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: steps: dict[str, list[str]] and start. Terminal steps have no outgoing edges (close, escalate). Report three lists: unreachable (never visited from start), trapped (reachable, but every pat...

High-Level Design
  1. Collect all node names, including referenced-only ones.
  2. Forward BFS from start gives the reachable set; the rest is unreachable.
  3. Build the reverse graph. Multi-source BFS from all terminals...

Submit Your Answer
Markdown supported

Related Questions