Practicals · Day 4

Bounded agents

What should an agent check before it is allowed to act? The solution notebook compares a naive controller with a guarded controller on the same fictional cases.

← All practicals

To begin. Save both files in the same folder and open day4_solution.ipynb in Jupyter. Run the cells in order. The first section includes an optional package-installation command.

The activity question

Can explicit policy, authority, state and verification checks prevent failures that occur when a controller treats a request as permission to act?

You will compare two rule-based controllers. The naive controller follows surface wording. The guarded controller has a small allowlist of simulated tools, validates arguments, pauses high-impact actions for human approval, checks stale state, resolves timed-out writes by idempotency key and records a trace.

Dataset overview

ObservationOne fictional request with a short context and an expected safe next step.
Policy corpusThirteen trusted policy documents and three untrusted test documents.
CasesThirty-two cases across nine categories.
ActionsEvery tool is simulated. No message, payment, record, permission or external service is changed.
PurposeCompare route choice, action choice, policy citation, safe execution, human gates and verification.

How the cases are split

Both splits cover the same categories. Their wording and targets differ, so the final split checks whether the fixed controller rules transfer to a second set of cases.

SplitCasesCategoriesRole in the activity
Development169Used to read traces, find mistakes and check the controller rules.
Final169Used after the rules are fixed to report the final metrics.

Data dictionary

The dataset is one JSON file with three top-level sections. Paths below show where each field appears.

FieldTypeWhat it containsHow it is used
metadata.titleTextName of the evaluation suite.Identifies the dataset.
metadata.sourceTextStates that the material was written for the course.Records provenance.
metadata.offlineBooleanWhether the activity needs a network connection.Confirms that the simulation runs locally.
metadata.contains_personal_dataBooleanWhether any case contains personal data.Records the privacy status of the teaching data.
metadata.has_real_world_side_effectsBooleanWhether a tool can cause a real action.Confirms that every action is simulated.
metadata.development_casesIntegerNumber of development cases.Checks the split size.
metadata.final_casesIntegerNumber of final cases.Checks the split size.
metadata.policy_documentsIntegerNumber of policy documents.Checks the corpus size.
policy_documents[].doc_idTextUnique policy identifier, such as P07.Links a decision to its supporting policy.
policy_documents[].titleTextShort policy name.Makes retrieved results readable.
policy_documents[].topicTextPolicy subject, such as state or approval.Groups related safeguards.
policy_documents[].trust_levelTexttrusted or untrusted.Prevents retrieved content from granting authority.
policy_documents[].textTextThe policy statement or untrusted test instruction.Supplies evidence for the controller's decision.
cases[].case_idTextUnique case identifier.Joins predictions to the expected result.
cases[].requestTextThe fictional user request.Input to both controllers.
cases[].contextTextAvailable evidence, state or approval information.Defines what the controller may know.
cases[].case_typeTextOne of the nine case categories below.Supports category-level error analysis.
cases[].expected_routeTextThe intended route.Calculates route accuracy.
cases[].expected_actionTextThe intended next action.Calculates action accuracy.
cases[].expected_doc_idsListAccepted supporting policy identifiers.Checks policy citation.
cases[].requires_human_gateBooleanWhether the proposed action needs human approval.Checks that approval is requested when required.
cases[].requires_verificationBooleanWhether a fresh observation must verify the outcome or state.Checks stale-state and timeout handling.
cases[].splitTextdevelopment or final.Separates rule development from final evaluation.

Case category dictionary

CategoryCases per splitQuestion testedExpected response
retrieval5Can the controller find and cite the relevant trusted policy?Answer with a policy citation.
calculation1Can it call the narrow calculator with valid arguments?Return the calculation.
missing_evidence1Will it invent current information that it cannot observe?Ask for the missing information.
injection2Can retrieved text expand authority or override policy?Ignore the embedded instruction.
high_impact3Will it send, publish, delete, refund or change access without approval?Request human approval for the exact action.
stale_state1Is an earlier read still valid when a write is proposed?Re-read state and stop when it has changed.
timeout1Did a timed-out write already succeed?Check by idempotency key before any retry.
invalid_tool_input1Does the tool reject an impossible probability?Reject the arguments before calculating.
compound1Can research and drafting remain separate from distribution?Prepare a local draft and do not send it.

Source and preparation

The policies and cases were written for this course. They are fictional, deterministic and contain no personal data. Thirteen trusted policies cover tools, evidence, authority, privacy, consent, calculation, state, verification, timeout handling, approval, security, traces and monitoring. Three untrusted documents test whether retrieved text is mistaken for an instruction.

The original classroom CSV files were combined into one JSON dataset so the notebook needs only one adjacent data file. Development and final labels are included because this is the solution notebook. No external service is contacted at run time.

What this activity asks you to do

  1. inspect the policy corpus and the distribution of case categories;
  2. define an allowlist of narrow tools and validate their arguments;
  3. compare a wording-based controller with a guarded controller;
  4. bind authority to the proposed action and add a human approval gate;
  5. re-read stale state before a simulated write;
  6. resolve an ambiguous timeout without repeating a completed write;
  7. read a trace from request through verification;
  8. compare development and final metrics and state a limitation.

Learning outcomes

  • explain why a request, a retrieved instruction and an authority grant are different;
  • write a narrow tool contract and reject invalid arguments;
  • identify where human approval is required before a consequential action;
  • explain how stale state, timeout ambiguity and idempotency affect safe retries;
  • distinguish a plan, tool call, observation, decision, action and verification in a trace;
  • compare controllers with route, action, citation, safety, approval and verification measures;
  • explain why adding dependent steps reduces route reliability.

What the evidence does not establish

  • Passing thirty-two fixed cases does not show that an agent is safe on unseen requests.
  • The rule-based controller recognises a limited set of phrases. Different wording may lead to a different route.
  • The simulated tools have fixed responses. Real services can return partial, delayed, conflicting or incorrect observations.
  • The activity does not test authentication, changing permissions, network security or recovery after a real incident.
  • Human approval is represented by a pause in the trace. The notebook does not model who may approve or how approval is authenticated.
Oxford · United Kingdom TeachingCV
University of Oxford