Agent Governance ToolkitAgent Governance Toolkit 4.1.0 · Python 3.10+
Dashboard
0%

Building the shop agent

The shop agent is the running example for the whole course: a deterministic stand-in that turns a support message into one tool call, so every lesson can govern it with no model key.

Last updated: 14 Oct, 2026 · Agent Governance Toolkit 4.1.0

The previous lesson showed why an agent needs a gate. This lesson packages that agent into one small module the rest of the course reuses, and is honest about the one piece that is faked: the model.

Standing in for the model

A production agent sends the message to a model and reads back the tool it chose. That needs a key and gives a different answer each run, which would make a course impossible to check. The stand-in keeps the same shape, the message in and a tool name plus arguments out, but decides with rules.

python
def decide(message):
    m = message.lower()
    if "refund" in m: return "refund", {"order_id": "A-2291", "amount": 40}
    if "status" in m or "where" in m: return "order_status", {"order_id": "A-2291"}
    if "close" in m or "delete" in m: return "delete_account", {"customer_id": "C-5"}
    return "reply", {"text": "How can I help?"}

The line that swaps in a real model

In production decide would call a model instead. The shape of the return is the same, so nothing downstream changes. This block is shown, not run, because it needs a key the course does not use.

python
# production version: ask a model, read back the chosen tool (needs a key, not run here)
from litellm import completion

def decide(message):
    reply = completion(model="groq/openai/gpt-oss-120b",
                       messages=[{"role": "user", "content": message}],
                       tools=TOOL_SCHEMAS)
    call = reply.choices[0].message.tool_calls[0]
    return call.function.name, json.loads(call.function.arguments)

Running the four message types

The tools and the run loop are the same as before. Running one message of each kind shows the router covering refunds, status checks, the dangerous close, and a fallback reply.

ExampleThe shop agent routing four messages
for msg in ["I want a refund", "where is my order?",
            "please close the account", "hello"]:
    name, args = decide(msg)
    print(f"{msg:28} -> {name:15} {TOOLS[name](**args)}")

What the router produced

  • Each message mapped to one tool, the way a model's tool call would, so later lessons can gate by the tool name.
  • The close still ran, because there is still no gate. That is the job of the govern() lesson next.
  • The output is the same every run, which is what lets the course check it. A real model would vary.

A stand-in vs a real model

The stand-inA real model
Decides withRules in PythonA prompt and tool schemas
Needs a keyNoYes
Same answer each runYesNo
Good forLearning and testsProduction

Where the stand-in agent fits

  • A test suite for a governed agent, where you want the tool choice fixed so the policy is what is under test.
  • A local demo with no key, to show the gate working before wiring a model in.
  • A replay of a captured session, feeding recorded tool choices back through the gate.
Watch out. The stand-in is only the model's job, picking a tool. Everything the course governs, the gate, the policy, the audit trail, is the real toolkit running for real. Swapping in a model changes how the tool is chosen, not how it is governed.
Try it yourself
  • Add a track_package tool and a rule in decide that routes track to it.
  • Make decide return a different order id when the message contains one.
  • Print the tool name and arguments only, without calling the tool, to see the model's decision on its own.

Slow is fine. Stopping is the only problem.