agentic_ai_basics

system_prompt

System Prompt — the fixed instruction set that defines an agent’s role, constraints, and available tools, sent with every request separate from the user’s message.

system_prompt.py

Sends the identical user question through the same call shape as ../basics/basic.py’s ask_claude, three times, under three different system prompts — a terse expert, an ELI5 tutor, and a strict JSON-only API. Everything about the request is the same except the system prompt.

Concepts covered

Run

From the repo root:

pip install -r requirements.txt
export ANTHROPIC_API_KEY=your-key-here
python3 Core_Architecture/system_prompt/system_prompt.py

Try (or press enter for the built-in default):

Question to send under every system prompt (blank for a default demo):
> Why does my Python code throw a KeyError when I access a dictionary?

Same question, 3 different system prompts:
  Why does my Python code throw a KeyError when I access a dictionary?

--- terse_expert ---
A KeyError happens when you access a dict key that doesn't exist. Use .get() or check with 'in' first.

--- eli5_tutor ---
Think of a dictionary like a row of labeled lockers -- each key is a label. If you ask for a locker
label that isn't there, Python can't find it and throws a KeyError to let you know!

--- strict_json_api ---
{"summary": "KeyError on dict access", "likely_cause": "requested key not present in the dictionary"}

Configuration

See also