Learn. Practice. Feel prepared.
50 AI Agents Interview Questions and Answers for Developers
Explore AI Agents interview questions and answers designed for developers building reliable LLM-powered applications. Learn how to design execution loops, integrate tools, manage context and memory, recover from failures, enforce permissions, and evaluate production agents through realistic engineering scenarios.
Top AI Agents Interview Questions for Freshers and Experienced
50 Questions
Easy · Medium · Hard
Try answering from memory, then check the reference answer and rate yourself. Your notes are optional and are not automatically graded.
1 How does an LLM-based agent differ from a deterministic workflow, and when would you choose each? easy
agent-fundamentalsdeterministic-workflowsarchitecture
Reference answer
A deterministic workflow follows predefined execution paths, while an LLM-based agent uses model decisions to select actions or determine subsequent steps.
A workflow is appropriate when business rules and execution sequences are known. An agent is useful when tasks require interpreting ambiguous requests or selecting among changing alternatives.
For example, invoice approval with fixed thresholds should use a workflow, while investigating an unfamiliar production incident may benefit from an agent that selects diagnostic tools.
The distinction is architectural rather than absolute; applications frequently combine both approaches.
Avoid defining every application that calls an LLM as an autonomous agent.
Did you know it?
2 What components are necessary to build a basic tool-using AI agent? easy
agent-architecturetool-callingexecution-loop
Reference answer
A basic tool-using agent needs a model interface, task instructions, available tool definitions, an execution controller, and a mechanism for returning results.
The controller sends context to the model, interprets proposed actions, executes permitted tools, and supplies observations for subsequent decisions.
For example, an order-support agent might use an order lookup API and a refund eligibility checker.
Persistent memory, vector databases, and multi-agent coordination are optional capabilities rather than universal requirements.
Did you know it?
3 Why is a model-generated tool call not equivalent to executing an authorized business operation? easy
tool-authorizationagent-securityexecution-control
Reference answer
A model-generated tool call is a proposed operation, not proof that the operation is permitted.
The application must validate arguments, authenticate the requester, enforce permissions, and apply relevant business rules before execution.
For example, an agent may propose transferring funds using valid JSON, but the backend must independently verify account ownership and transaction limits.
Separating proposals from execution prevents model output from becoming an uncontrolled authorization mechanism.
Did you know it?
4 What is the purpose of an agent execution loop? easy
execution-looptool-callingtermination
Reference answer
An execution loop allows an agent to alternate between model decisions, tool execution, and observation of results until the task finishes or a stopping condition is reached.
A typical cycle is model request, action proposal, validation, tool execution, result collection, and another model request.
For example, a troubleshooting agent might inspect logs, query metrics, and then produce a diagnosis.
The controller should enforce limits on iterations, time, and spending rather than relying entirely on the model to stop.
Did you know it?
5 How should an agent decide whether to call a tool or answer directly? easy
tool-selectionagent-decisionstool-use
Reference answer
The decision should depend on whether the task requires external information, computation, or a real-world action unavailable from the model's existing context.
Tool descriptions help the model select capabilities, while application rules can require particular tools for authoritative or sensitive operations.
For example, checking a live account balance requires an account API, while explaining a general programming concept may not require any tool.
Unnecessary calls increase latency and cost, whereas skipping necessary calls risks unsupported answers.
Did you know it?
6 What is the difference between conversation context and persistent application state in an AI agent? easy
conversation-contextpersistent-statememory
Reference answer
Conversation context is information supplied to the model for a particular inference, while persistent application state is durable information maintained outside the model.
Context may contain recent messages and tool results. Persistent state may contain workflow status, approved actions, checkpoints, and user preferences.
For example, an order cancellation recorded in a database must remain valid even when earlier conversation messages are removed from the model context.
A model's context window should never be treated as the authoritative system of record.
Did you know it?
7 How does retrieval differ from long-term memory in an agent application? easy
retrievallong-term-memorycontext-management
Reference answer
Retrieval fetches relevant information from an external source, while long-term memory stores information intended for reuse across interactions or tasks.
Retrieval can search documents, databases, or APIs without permanently remembering the returned information.
For example, searching a product manual is retrieval, while saving a user's preferred notification language is a long-term memory operation.
Both require access controls and lifecycle policies, and neither automatically requires a vector database.
Did you know it?
8 Why should an AI agent use bounded retries when external tools fail? easy
retry-policytool-failuresreliability
Reference answer
Bounded retries help recover from transient failures without creating endless execution loops or excessive external requests.
A retry policy should consider error type, maximum attempts, backoff, deadlines, and whether repeating the operation is safe.
For example, a temporary read-only API failure may justify retrying, while a payment request with an unknown outcome requires additional safeguards.
Retry frequency alone does not establish retry safety; repeated operations may create duplicate side effects.
Did you know it?
9 What information should be captured in an agent execution trace? easy
agent-tracingobservabilitydebugging
Reference answer
An execution trace should record the task identifier, model and configuration versions, tool decisions, validated arguments, execution outcomes, timestamps, and state transitions.
These records allow engineers to reconstruct observable behavior without requiring access to hidden model reasoning.
For example, a trace can show that an agent queried an outdated inventory source before incorrectly confirming availability.
Sensitive arguments and tool responses should be redacted or access-controlled, and traces should use correlation identifiers across services.
Did you know it?
10 What is the difference between a successful tool response and successful completion of a user's task? easy
task-successtool-resultsevaluation
Reference answer
A successful tool response means an individual operation completed according to its API contract, while task success means the user's intended outcome was achieved.
An HTTP 200 response may contain incomplete information, a business-level rejection, or data unrelated to the original request.
For example, successfully retrieving a flight itinerary does not mean the agent completed a requested flight cancellation.
Agent evaluation must therefore measure end-to-end outcomes rather than treating successful API calls as completed tasks.
Did you know it?
11 A customer-support process has five predictable steps but one step requires interpreting free-form complaints. How would you design the workflow? medium
hybrid-architectureworkflow-designllm-classification
Reference answer
Use a deterministic workflow for the predictable steps and introduce a bounded LLM decision component only where language interpretation is necessary.
The application should control transitions, permissions, and completion criteria, while the model classifies the complaint or extracts structured information.
For example, the workflow can authenticate the customer, classify the complaint, retrieve the order, apply refund rules, and generate a response.
This hybrid design limits unnecessary autonomy while preserving flexibility for ambiguous user input.
Did you know it?
12 An agent can either execute a direct tool call or create a multi-step plan. What factors should determine the choice? medium
agent-planningtask-decompositionexecution-strategy
Reference answer
Use direct execution for simple, well-defined operations and planning when the task involves dependencies, uncertainty, or multiple coordinated actions.
Planning introduces overhead and can become stale when tool results invalidate assumptions. The controller should permit replanning when necessary.
For example, fetching a single invoice needs no elaborate plan, while investigating inconsistent financial reports may require querying multiple sources and reconciling results.
A useful plan identifies dependencies, expected outputs, and completion conditions rather than merely generating a long list of actions.
Did you know it?
13 An agent repeatedly calls the same search tool with identical arguments and receives the same results. How would you detect and stop this behavior? medium
infinite-loopsprogress-detectiontermination
Reference answer
Track normalized tool names, arguments, result fingerprints, and whether each iteration makes measurable progress toward the task.
If repeated calls produce equivalent observations without changing state or resolving uncertainty, the controller should block further identical calls and trigger a fallback.
For example, after two unchanged searches, the agent could reformulate its query, request clarification, or return a partial answer.
Enforce maximum iterations and deadlines as independent safeguards, and inspect traces to distinguish genuine pagination from a nonproductive loop.
Did you know it?
14 An agent selects a refund API instead of an order-status API, even though the generated arguments satisfy the refund API schema. What went wrong? medium
semantic-correctnesstool-selectiontool-validation
Reference answer
The failure is semantic tool selection, not argument-schema validation. A valid tool call can still be inappropriate for the user's intention.
Investigate overlapping tool descriptions, ambiguous instructions, insufficient context, and missing policy constraints.
For example, a request to check refund eligibility should not automatically execute a refund. Separate eligibility checking from refund creation and require explicit authorization for mutations.
Test tool selection using intent-labelled examples and measure inappropriate action attempts independently of JSON validity.
Did you know it?
15 How would you implement a termination policy for an agent that investigates production incidents? medium
termination-policyincident-responseexecution-limits
Reference answer
Define termination through task completion, explicit user cancellation, iteration limits, deadlines, budget limits, and detection of nonproductive behavior.
The controller should distinguish successful diagnosis from insufficient evidence and operational failure rather than forcing every execution to produce a confident answer.
For example, stop after a fixed diagnostic deadline and return verified findings, unresolved hypotheses, and recommended manual checks.
A model-generated final response is not sufficient evidence of completion; validate required outputs and tool observations before marking the task successful.
Did you know it?
16 An agent must create a support ticket and then notify the customer. How should dependencies between tool calls be enforced? medium
tool-dependenciesworkflow-stateexecution-order
Reference answer
Represent the operations as dependent steps and require verified ticket creation before allowing the notification step.
The controller should pass the actual ticket identifier from the first result rather than accepting a model-invented identifier.
For example, if ticket creation fails, the notification step should not claim that a ticket exists. If notification fails, retain the ticket identifier for safe recovery.
Persist step statuses so retries resume from the incomplete operation instead of restarting the entire workflow.
Did you know it?
17 A tool returns a valid JSON response containing a business error. Why might the agent incorrectly continue, and how would you fix it? medium
tool-responsebusiness-errorserror-handling
Reference answer
The agent may confuse syntactic validity or transport success with business success, especially when tool responses lack consistent outcome semantics.
Normalize tool responses into explicit statuses such as SUCCESS, REJECTED, RETRYABLE_FAILURE, and UNKNOWN_OUTCOME, while preserving relevant error details.
For example, an HTTP 200 response containing an insufficient-funds error must not advance a payment workflow to completion.
The execution controller should validate business postconditions before permitting dependent actions, and tests should cover successful transport with failed business operations.
Did you know it?
18 How should an agent handle a user request that requires a capability not exposed by its available tools? medium
capability-boundariestool-routinggraceful-degradation
Reference answer
The agent should identify the missing capability and avoid inventing an execution result or misusing an unrelated tool.
The controller can offer a supported alternative, request additional information, or route the task to an authorized external workflow when one exists.
For example, an agent with read-only calendar access must not claim that it rescheduled a meeting.
Tool availability should be treated as an explicit capability boundary, and the final response should distinguish completed operations from instructions the user must perform.
Did you know it?
19 How would you decide which conversation messages and tool results to retain when an agent approaches its context limit? medium
context-windowcontext-compactiontoken-management
Reference answer
Retain information according to task relevance, authority, recency, and whether it represents unresolved commitments or required execution state.
Summarize older conversation segments, discard redundant tool output, and preserve critical identifiers and constraints in structured application state.
For example, a research agent can summarize earlier search results while retaining the user's original requirements and verified source references.
Summarization may lose important details, so maintain provenance and test whether compressed context still supports correct decisions.
Did you know it?
20 An agent gives different answers to the same question because its retrieved documents change between executions. How would you make the behavior auditable? medium
retrieval-provenancereproducibilitydocument-versioning
Reference answer
Record the retrieval query, document identifiers, source versions, retrieval timestamps, ranking configuration, and relevant document excerpts.
These records distinguish changes in retrieved evidence from changes in model behavior or prompting.
For example, an internal policy agent may answer differently after a revised leave policy replaces an older document.
For reproducible testing, use a versioned retrieval snapshot or controlled fixture set. Production responses should identify source freshness where it materially affects correctness.
Did you know it?
21 A user corrects an agent's previously remembered preference. How should the memory system handle the correction? medium
memory-updatespreference-managementdata-consistency
Reference answer
Treat the correction as a controlled update to persistent memory rather than simply appending contradictory facts to conversation history.
Identify the relevant memory record, verify that the requester can modify it, and apply an update with appropriate versioning or supersession metadata.
For example, replace a preferred notification channel of email with SMS after an authorized user changes the preference.
The system should avoid retrieving obsolete values as equally authoritative and should support deletion or expiry according to the application's data-retention requirements.
Did you know it?
22 How would you prevent an agent from treating low-confidence retrieved information as an established fact? medium
retrieval-qualitysource-trustgrounded-responses
Reference answer
Preserve source provenance, assess relevance and authority, and distinguish retrieved claims from verified application facts.
The agent should use corroboration, freshness checks, or authoritative APIs when the consequences of an incorrect claim are significant.
For example, a financial assistant should not calculate an account's available balance from an old document when a current account API exists.
A similarity score alone is not a factual confidence guarantee, and the application should allow the agent to report uncertainty or insufficient evidence.
Did you know it?
23 An agent's API request times out after submitting a payment, but the payment may already have succeeded. How would you prevent duplicate charges? medium
idempotencypayment-retriesunknown-outcome
Reference answer
Treat the timeout as an unknown outcome rather than assuming failure, and use a stable idempotency key associated with the logical payment operation.
If the payment provider supports idempotency, retries should reuse the same key and equivalent request parameters. Otherwise, reconcile the operation using an authoritative transaction lookup before resubmission.
Persist the operation identifier and status before initiating the external action.
Never generate a fresh payment request solely because the original HTTP response was lost; that can turn a transient network failure into a duplicate financial side effect.
Did you know it?
24 A tool occasionally returns HTTP 429 responses. How should an agent distinguish rate limiting from permanent failure? medium
rate-limitingexponential-backoffretry-classification
Reference answer
Classify HTTP 429 as a rate-limiting response and apply a bounded retry policy that respects a valid Retry-After header when supplied.
Use exponential backoff with jitter, concurrency controls, and an overall execution deadline. Permanent validation or authorization failures should generally not receive the same retry treatment.
For example, a document retrieval agent can wait briefly before retrying a throttled search request, but should not repeatedly submit malformed arguments.
When the retry budget is exhausted, preserve partial progress and return a clear recoverable failure status.
Did you know it?
25 An agent completes three of five workflow steps before its process crashes. How would you resume execution safely? medium
checkpointingcrash-recoverydurable-execution
Reference answer
Persist durable checkpoints containing completed steps, verified outputs, pending operations, and external action identifiers.
On recovery, reconstruct the workflow from the latest committed checkpoint and reconcile any operation whose outcome is uncertain.
For example, if a report was generated and uploaded before the crash, resume with the remaining notification steps rather than uploading the report again.
Checkpoint updates should be coordinated with side-effect tracking because saving a checkpoint and executing an external API call are not automatically atomic.
Did you know it?
26 How would you design fallback behavior when an agent's primary external search service becomes unavailable? medium
fallback-strategyservice-outagesgraceful-degradation
Reference answer
Define fallback options according to task requirements, source reliability, and whether reduced functionality is acceptable.
The controller can switch to an approved secondary provider, use sufficiently fresh cached data, or stop with a partial result when authoritative information is unavailable.
For example, a documentation assistant may use a mirrored documentation index, while a live trading assistant should not silently substitute stale prices.
Record which fallback was used and expose relevant limitations to the user. A fallback should preserve safety and correctness requirements rather than merely produce an answer.
Did you know it?
27 An agent receives an HTTP 200 response from a tool but the response is missing a required field. How would you investigate? medium
schema-validationapi-contractstool-debugging
Reference answer
Inspect the raw response, validate it against the expected output contract, and compare the deployed tool version with the agent's schema definition.
Possible causes include API contract changes, partial backend failures, inconsistent response variants, or incorrect deserialization.
For example, an order lookup returning a null orderId must not be accepted as a successfully retrieved order when subsequent actions require that identifier.
Introduce runtime schema validation, contract tests, and structured error reporting so malformed responses fail explicitly instead of contaminating later model decisions.
Did you know it?
28 How should an agent protect itself when retrieved webpage content contains instructions to ignore its original task and send data elsewhere? medium
prompt-injectionuntrusted-contenttool-security
Reference answer
Treat retrieved webpage content as untrusted task data, not as an instruction source with authority over the agent's behavior.
Separate trusted instructions from retrieved content, constrain available tools, and enforce destination and data-access policies outside the model.
For example, a webpage claiming that the agent must upload customer records to an external endpoint should not gain permission to invoke an upload tool.
Test the system with adversarial documents and inspect whether malicious content influences proposed actions. Prompt wording alone is not a sufficient security boundary.
Did you know it?
29 An agent has permission to read customer records but not modify them. How would you enforce that restriction? medium
least-privilegeauthorizationtool-permissions
Reference answer
Enforce read-only access through backend authorization and tool-level capabilities rather than relying on instructions telling the model not to modify records.
Expose only necessary operations, bind authorization to the authenticated principal, and validate permissions for every requested action.
For example, the agent may receive customerLookup access while customerUpdate remains unavailable or consistently rejected by the service.
Use scoped credentials and audit access attempts. Even a valid model-generated request must fail if the underlying principal lacks the required permission.
Did you know it?
30 A user approves a bank transfer, but the agent changes the recipient account before execution. Should the original approval remain valid? medium
human-approvalapproval-integritytransaction-security
Reference answer
No. Approval should be bound to the specific action and material parameters that the user reviewed.
Represent the approved operation using a canonical parameter set or integrity-protected action record, and verify that the executable request still matches it.
For example, changing the recipient, amount, currency, or source account should invalidate the earlier transfer approval and require renewed confirmation.
Approvals should also have appropriate expiry, scope, and single-use semantics. Human oversight is ineffective when the executed operation differs from the approved operation.
Did you know it?
31 How would you evaluate whether an AI agent actually completes customer-support tasks correctly? medium
task-evaluationsuccess-metricsagent-testing
Reference answer
Build a representative evaluation dataset with user goals, initial system states, permitted actions, and independently verifiable expected outcomes.
Execute the agent in a controlled environment and measure task completion, policy violations, incorrect side effects, and recovery behavior.
For example, a cancellation task succeeds only when the correct reservation is cancelled and the resulting state is verified, not merely when the agent produces a convincing confirmation.
Include ambiguous requests, unavailable tools, and permission failures to test behavior beyond ideal examples.
Did you know it?
32 An agent produces correct answers but its average execution time has doubled. How would you locate the latency regression? medium
latency-analysisdistributed-tracingperformance
Reference answer
Break total execution time into model inference, tool calls, retrieval, queueing, retries, and application processing.
Use correlated traces to compare step counts and latency distributions before and after the regression, including tail latency rather than averages alone.
For example, an increase from three to seven sequential model calls may explain the slowdown even when individual inference latency is unchanged.
Optimize the dominant component through caching, safe parallelism, fewer unnecessary calls, or smaller context payloads while monitoring task quality.
Did you know it?
33 A model upgrade improves standalone reasoning benchmarks but reduces the agent's end-to-end task success rate. How would you investigate? medium
model-upgradesregression-testingsystem-quality
Reference answer
Compare the old and new models using the same task fixtures, tools, permissions, and environment state.
Inspect observable differences in tool selection, argument correctness, unnecessary calls, termination behavior, and handling of tool errors.
For example, the new model may generate better explanations while selecting a read-only lookup tool instead of the required mutation tool.
Use trace-level failure classification and task outcome metrics rather than assuming stronger model benchmarks imply better agent performance. Roll out upgrades through controlled evaluations and gradual deployment.
Did you know it?
34 An agent frequently exceeds its permitted token-spending budget. How would you control cost without simply reducing answer quality? medium
cost-optimizationtoken-budgetmodel-routing
Reference answer
Track estimated and actual spending across model calls, tool usage, retrieval, and retries using a per-task budget ledger.
Introduce pre-call budget checks, bounded execution steps, context compaction, and model routing based on task complexity.
For example, use a lower-cost model for classification while reserving a stronger model for difficult planning or final verification.
When the remaining budget cannot support safe completion, stop gracefully with partial findings. Evaluate cost per successful task rather than minimizing tokens without considering outcomes.
Did you know it?
35 How would you test an agent's handling of tool failures without depending on unpredictable production outages? medium
fault-injectionintegration-testingfailure-simulation
Reference answer
Use controlled tool simulators or fault-injection layers that reproduce specific failure modes with repeatable inputs.
Test timeouts, rate limits, malformed responses, partial success, authorization rejection, and delayed results while recording expected state transitions.
For example, simulate a successful external write followed by a lost response to verify that recovery does not duplicate the operation.
Combine deterministic integration tests with broader model-based evaluations because fixed mocks cannot capture every model decision or real-world service behavior.
Did you know it?
36 When would you choose a single agent over multiple specialized agents for a complex software-development task? medium
multi-agentagent-specializationarchitecture-tradeoffs
Reference answer
Start with a single agent when the task can be handled using one coherent context, a manageable tool set, and a bounded execution loop.
Introduce specialized agents when independent responsibilities, distinct permissions, or parallelizable subtasks justify the coordination overhead.
For example, separate code analysis and security review agents may be useful when each has different tools and evaluation criteria.
Multiple agents introduce communication costs, inconsistent assumptions, and additional failure paths. Compare measured task quality, latency, and operational complexity before adopting the architecture.
Did you know it?
37 What problem does Model Context Protocol (MCP) address when integrating tools with an AI agent? medium
mcptool-integrationprotocol-design
Reference answer
MCP defines a standardized communication model through which compatible clients and servers expose capabilities such as tools and contextual resources.
It reduces the need to design a completely separate integration contract for every supported capability, while leaving execution policy and application authorization to the surrounding system.
For example, an MCP-compatible client may discover a database-query tool exposed by an MCP server rather than relying on a custom integration format.
MCP does not automatically make tools safe, trustworthy, or necessary for every agent architecture.
Did you know it?
38 An agent works correctly in development but intermittently fails when deployed across multiple application replicas. How would you investigate state-related causes? hard
distributed-statehorizontal-scalingstate-consistency
Reference answer
Check whether conversation state, execution checkpoints, and tool-operation identifiers are stored only in replica-local memory.
Requests routed to different replicas may lose prior context or observe inconsistent workflow progress if shared state is not durable and coordinated.
For example, an agent may repeat an external operation when the next request reaches a replica that lacks the original completion record.
Use shared persistent storage where necessary, enforce concurrency controls, and trace requests using stable task identifiers across replicas.
Did you know it?
39 An agent must execute several independent read operations and one destructive operation. How would you design safe parallel execution? hard
parallel-tool-callsdependency-graphconcurrency
Reference answer
Construct an explicit dependency graph and execute independent read-only operations concurrently when their consistency requirements permit it.
Keep the destructive operation behind verified prerequisites, authorization checks, and any required human approval. Do not assume all tools are safe to parallelize.
For example, an agent may fetch inventory and pricing concurrently but must verify the final order state before cancelling an existing reservation.
Use deadlines, cancellation propagation, and deterministic aggregation of results. Shared-state mutations require synchronization or transactional coordination to avoid race conditions.
Did you know it?
40 An agent's planner produces a valid sequence of actions, but an intermediate tool result invalidates the original plan. How should execution adapt? hard
dynamic-replanningplan-validationexecution-recovery
Reference answer
Treat the plan as a revisable execution hypothesis rather than an immutable script.
After each meaningful observation, evaluate whether remaining steps still satisfy their prerequisites and whether the original objective remains achievable.
For example, a travel-booking agent may plan a hotel reservation after selecting a flight, but a failed flight booking should invalidate dependent hotel actions.
Replanning should preserve completed side effects, approval boundaries, and the remaining budget. Avoid restarting blindly because already executed operations may not be reversible.
Did you know it?
41 How would you design an agent controller that can distinguish genuine task progress from repeated but superficially different actions? hard
progress-metricsloop-detectionagent-controller
Reference answer
Define progress using observable task-state changes and verified subgoal completion rather than relying on the number or diversity of tool calls.
Track evidence gained, unresolved requirements, completed outputs, and whether new observations materially change the agent's decision state.
For example, repeatedly searching different keywords that return the same documents should not count as progress toward finding a missing contract clause.
Use semantic result deduplication, bounded exploration, and explicit escalation conditions. A progress detector should tolerate legitimate iterative searches without allowing indefinite activity.
Did you know it?
42 A multi-tenant agent accidentally retrieves memory belonging to another user. How would you identify the root cause and prevent recurrence? hard
memory-isolationmulti-tenancydata-leakage
Reference answer
Investigate whether retrieval filters, cache keys, storage partitions, or authorization checks failed to enforce tenant and user boundaries.
Reproduce the issue using isolated test identities and inspect retrieval requests, returned document ownership, and cache behavior without unnecessarily exposing sensitive content.
For example, a vector search restricted only by semantic similarity may retrieve another tenant's stored preferences if tenant filtering is missing.
Enforce access control in the retrieval service, use scoped cache keys, and test cross-tenant isolation. Treat the incident as a potential data exposure requiring appropriate response procedures.
Did you know it?
43 An agent uses retrieved documents to generate a financial recommendation, but the documents contain conflicting figures. How would you design reliable evidence reconciliation? hard
evidence-reconciliationretrieval-reliabilitydata-provenance
Reference answer
Preserve document provenance, timestamps, units, and authority levels, then reconcile conflicting figures before using them in calculations.
Prefer authoritative structured sources where available, and apply explicit rules for reporting periods, currencies, and document versions.
For example, an annual report and a quarterly update may contain different revenue values because they describe different periods rather than contradictory facts.
If reconciliation fails, report the disagreement and avoid presenting a single unsupported figure. Evaluate both evidence selection and downstream calculations.
Did you know it?
44 An agent updates a database and publishes an event, but crashes between those operations. How would you maintain consistency without assuming distributed transactions? hard
transactional-outboxevent-consistencydistributed-recovery
Reference answer
Use a transactional outbox or equivalent durable coordination mechanism so the database change and intent to publish are committed together.
A separate publisher delivers pending events, while consumers handle duplicate deliveries using stable event identifiers and idempotent processing.
For example, an agent marking an order as cancelled should atomically store the cancellation and an event record before an asynchronous worker publishes the notification.
This design provides recoverable delivery but does not automatically guarantee exactly-once external effects. Monitor pending events and reconcile failed deliveries.
Did you know it?
45 An agent executes three external operations, but the final operation fails after the earlier ones have committed. How would you design recovery? hard
saga-patterncompensating-actionspartial-failure
Reference answer
Model the process as a durable saga with explicit operation states, compensating actions where feasible, and escalation paths for irreversible effects.
Compensation is a new business operation, not a guaranteed rollback, so it may fail or require human intervention.
For example, a travel agent that booked a flight and hotel but failed to reserve a vehicle may need to cancel earlier bookings according to refund policies.
Record each confirmed outcome and compensation attempt. Recovery should preserve an accurate account of partial completion rather than claiming atomicity across unrelated external systems.
Did you know it?
46 An agent retries a database write after a network failure, but the database operation does not support idempotency keys. How would you make retries safer? hard
deduplicationoptimistic-lockingretry-safety
Reference answer
Introduce application-level operation identifiers and enforce uniqueness or conditional updates within the database transaction.
For inserts, use a unique business-operation key. For updates, consider version checks or compare-and-set semantics to prevent stale writes.
For example, a request to issue a refund can store a unique refundRequestId and reject another insert with the same identifier.
After an ambiguous timeout, query the authoritative operation record before retrying. Safe retry design must account for concurrency, business semantics, and failures occurring after commit but before acknowledgment.
Did you know it?
47 How would you secure an agent that can execute shell commands while investigating production failures? hard
sandboxingcommand-executionleast-privilege
Reference answer
Treat model-proposed commands as untrusted execution requests and place command execution behind an independently enforced security boundary.
Use isolated execution environments, narrowly scoped credentials, command or capability restrictions, resource limits, and approval for sensitive operations.
For example, reading selected application logs may be allowed while modifying firewall rules or deleting production files requires separate authorization.
Capture sanitized execution records and enforce network and filesystem restrictions. A prompt telling the agent to avoid dangerous commands is not a substitute for technical isolation.
Did you know it?
48 An agent returns the correct final answer but performs an unauthorized intermediate data modification. How should its evaluation and monitoring detect this? hard
trajectory-evaluationsafety-invariantsside-effect-auditing
Reference answer
Evaluate both the final outcome and the complete observable execution trajectory, including tool calls, authorization decisions, and state changes.
Define independent safety invariants that fail the evaluation whenever prohibited operations occur, regardless of the final answer's accuracy.
For example, a reporting agent that temporarily modifies customer records before generating a correct report must be classified as unsafe.
Use isolated test environments with state-difference checks and production audit trails. Aggregate success rates should not conceal critical intermediate violations.
Did you know it?
49 Two specialized agents concurrently update the same shared task state and overwrite each other's progress. How would you redesign coordination? hard
multi-agent-coordinationshared-stateconcurrency-control
Reference answer
Avoid unrestricted shared-state writes by introducing explicit ownership, versioned updates, or a coordinating component that serializes conflicting mutations.
Optimistic concurrency control can reject stale updates, while append-only events or isolated agent workspaces can preserve independent contributions.
For example, a research agent and a drafting agent should publish separate artifacts or versioned state changes instead of replacing the same mutable document snapshot.
Define merge rules and conflict-resolution behavior, and test concurrent execution. Adding agents without state coordination can reduce reliability even when individual agents work correctly.
Did you know it?
50 An agent integrates with an MCP server that exposes a file-deletion tool. How would you design the integration to prevent unauthorized deletion and handle uncertain execution outcomes? hard
mcp-securitydestructive-toolsexecution-recovery
Reference answer
Treat the MCP server's advertised tool schema as an interface description, not as authorization to execute every requested operation.
The client application should authenticate the user, enforce file-level permissions, validate canonical paths, and require appropriate approval before invoking destructive actions.
For example, an approved deletion should bind the exact file identifier and relevant parameters to the authorization decision. If the call times out, reconcile the file's state before retrying.
Use trusted server configuration, scoped credentials, audit records, and explicit recovery rules. MCP interoperability does not replace application security or reliable execution design.
Did you know it?
0 / 0 answered