Cyberlium

AI › Module 2 › Lesson 2

BeginnerModule 2Lesson 2/5

Context and Tools

Context and tools literacy names context windows, RAG retrieval, and function calling — map data flow on YOUR $AI_LAB before adding plugins.

15 min+40 XP3 quiz
Module progress2 of 5

Visual · t32_context_and_tools

Context and tools literacy. $AI_LAB only. Original Cyberlium.

Opening

What the model sees is the attack surface — literacy teaches context assembly and tool permissions on toys you own.

Context includes system prompt, conversation history, retrieved documents (RAG), and tool definitions the model may invoke. Tool calling lets LLMs execute functions — file read, API call, database query — creating agency risk if boundaries are weak. Context window limits truncate older messages — literacy names what enters each request. Cyberlium maps context and tools on YOUR $AI_LAB — paper diagram of toy chatbot data flow. Next: Trust Boundaries.

1. Context and tool components (named)

Context window: maximum tokens per request including history. RAG: retrieval augments prompt with external documents. Tool schema: JSON describing callable functions. Tool result: output fed back into context for next turn.

On $AI_LAB, sketch context assembly for toy chatbot — system, history, one fictional RAG doc, one tool.

Command guide

Try these commands — Context and tool components (named)

═══ TOOLS & WEBSITES ═══ Browse / read these (authorized learning only — stay in YOUR lab / program scope)

OpenAI function calling — https://platform.openai.com/docs/guides/function-calling (tool-use literacy) OWASP LLM Top 10 — https://owasp.org/www-project-top-10-for-large-language-model-applications/ (LLM06 Excessive Agency) MITRE ATLAS — https://atlas.mitre.org/ (AI system components)

═══ INSTALL ═══

Linux (Debian/Ubuntu):

Command — copy this

sudo apt install python3

macOS:

Command — copy this

brew install python3

Windows: Download https://python.org/downloads/

═══ LINUX / macOS ═══

Command — copy this

export AI_LAB=${AI_LAB:-$HOME/cyberlium-lab/t32-ai}
cat > "$AI_LAB/notes/context-and-tools-literacy.md" <<'EOF'
# Context and Tools Literacy
## Context
- System prompt + user messages + retrieved docs (RAG) = model input
- Untrusted content in context can influence output (indirect injection risk)
## Tools / plugins
- LLM may call APIs, run code, query DB — trust boundary expands
- Defenses: allowlists, human-in-the-loop, scoped credentials
Lab: document shapes — no live stranger API scraping
EOF

Command — copy this

grep -E 'Context|Tools|trust boundary' "$AI_LAB/notes/context-and-tools-literacy.md"

Primary tools to practice this lesson: grep, python3. Reference sites: OpenAI function calling (https://platform.openai.com/docs/guides/function-calling); OWASP LLM Top 10 (https://owasp.org/www-project-top-10-for-large-language-model-applications/); MITRE ATLAS (https://atlas.mitre.org/). Run every command in the box — install first, then the usage lines — only on YOUR lab / program scope.

2. Why context literacy reduces surprise behavior

Indirect injection hides in retrieved docs — defenders audit what enters context. Excessive tool permissions enable data exfil — narrow tool scope on lab toys before production.

Students diagram context flow on sandbox — change control on employer prod is ticket + peer review.

3. Literacy ≠ prod plugin surgery without ticket

Forbidden: adding unrestricted file-read tools to employer copilot without approval. Allowed: context and tools card — data flow diagram for $AI_LAB fictional bot.

Ship: context and tools card for YOUR lab toy. Next: Trust Boundaries.

4. What you ship: context and tools card for $AI_LAB

Data flow diagram with RAG and tool nodes. $AI_LAB named. NO prod without ticket. chmod 600.

5. What you record before the next lesson

Date. Context and tools card. $AI_LAB named. File t32-m02-l02-context-and-tools.txt chmod 600.

6. Wrong vs right: stranger SaaS vs YOUR toy LLM

Worked failure — same MSF word, opposite target. Right never needs a café Wi-Fi or classmate laptop.

  • Wrong

    Grant file-read tool to lab bot without scope review. Add employer prod plugin without ticket.

  • Right

    Write context and tools card for YOUR $AI_LAB toy. Next: Trust Boundaries.

Mission: diagram context flow on YOUR lab toy

1) Draw system, history, RAG, tool nodes. 2) Label one data source as trusted vs untrusted. 3) Note one tool permission trim idea. 4) chmod 600.

Stuck? Ask Cyberlium AI Mentor

Untrusted data in context is indirect injection fuel — label sources early.

Knowledge Check

1

APPLY: RAG primarily:

Multiple choice

Knowledge Check

2

APPLY: True or False: Tool calling gives LLMs ability to invoke external functions.

True or False

Knowledge Check

3

APPLY: Context literacy on Cyberlium means:

Multiple choice

← Previous

Answer all 3 knowledge checks to continue. (0/3 answered)