Skip to content

Revamp: one llm.py, schemas in place of prefill, prompt caching - #1

Merged
Param-Harrison merged 4 commits into
mainfrom
revamp/agentic-2026
Dec 2, 2026
Merged

Param-Harrison merged 4 commits into
mainfrom
revamp/agentic-2026

Conversation

@Param-Harrison

@Param-Harrison Param-Harrison commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Revamp of this workshop, following curriculum/workshop-kit/REVAMP.md (row: practical-prompt-engineering-workshop). The 14 lessons keep their order and story.

What changed

  • One model file. llm.py from the kit makes every call. All 14 notebooks call llm.chat and read .text. The copied get_completion helpers, %pip cells, DEFAULT_MODEL fallbacks and log silencing are gone. Outputs and execution counts are cleared.
  • temperature removed from 01, 02, 03, 09 and 10. Current Claude models reject it.
  • Prefill replaced.
    • 05 section 3 now shows the problem first: JSON asked for in words, which json.loads may fail to read. It explains why prefill is gone. A new section 4 uses schema= with a pydantic class. Exercise 1 now uses a system prompt, and exercise 2 uses a list schema.
    • 07: the unused prefill argument is dropped.
    • 11 cell 6: a nested Order schema replaces prefill="{". Section 3 adds a CheckedOrder schema with a thinking field first, next to the existing tags version.
  • Added: prompt caching in 09. A Space Race rule book of 500 board spaces (about 8,000 tokens by a rough 4 characters per token count) goes in a system block marked cache_control. Two questions print Reply.input_tokens and Reply.cached_tokens.
  • Fixes: "In this finally chapter" (10). Chapter 10's ending said the workshop was complete, but four chapters follow, so it now points to them. "Proving examples" (07), "spliting" (12). The urgency string compare in 12. README lesson names now match each notebook's title.
  • Deleted hints.py. No notebook imports it.
  • Docs: the README is rewritten with the kit's sections and a new picture (docs/images/prompt-parts.svg). AGENTS.md is short now, and CLAUDE.md is @AGENTS.md. env.example lists only what the code reads, starting from the kit's file. The Google and DEFAULT_MODEL settings are gone.
  • Dependencies: jupyterlab, litellm>=1.111.1, pydantic, python-dotenv, with floors from today's lock. The dev group has ipykernel, nbclient and nbformat. requires-python = ">=3.11,<3.13", plus a .python-version file. Unused packages are dropped: colorama, ipywidgets, langchain-google-genai, mcp, nest-asyncio, pillow and requests.
  • Makefile: retitled from "AI Foundation". It keeps only working targets and adds make check and make verify.
  • Docker: the image and container are named practical-prompt-engineering-workshop. The mount .:/workspace now matches WORKDIR, and the venv lives in /opt/venv, so the mount does not hide it. The uv image is pinned, the unused Node.js install is gone, and the port binds to 127.0.0.1 only.

Not in this PR: .github/workflows/check.yml

The push token here has no workflow scope, so GitHub refused the kit's workflow file. Please add it from the kit, unchanged:

sh ../curriculum/workshop-kit/sync.sh .
git add .github/workflows/check.yml && git commit -m "Add the offline check workflow" && git push

Tested here, with no key

  • uv run python scripts/check.py prints check: 0 problems.
  • uv sync --locked. Every dependency imports.
  • Clean clone: make setup, then make check, then JupyterLab serves http://localhost:8888/lab. A call with no key stops with the No key found message.
  • Every notebook passes nbformat.validate, and every code cell parses.
  • Every notebook ran end to end in a kernel with a fake litellm.completion, wrapped by llm.py's own meter. The fake asserted that no request sends temperature or ends with an assistant message. 05 sent Haiku and Haikus schemas, and 11 sent Order and CheckedOrder. In 09, the request carried cache_control, and a faked cache read came back through Reply.cached_tokens.
  • Docker: the image built and docker compose up -d served JupyterLab. Inside the container, /workspace held the notebooks and import llm worked. One caveat: this sandbox could not fetch the ghcr.io/astral-sh/uv:0.11.32 layer, so that one build used a local uv binary in its place.

Only a paid run can prove

  • The real answers in every notebook, and whether the exercise checks pass on Haiku.
  • That Haiku honours schema= for the nested Order and CheckedOrder classes in 11.
  • That the 09 rule book is long enough for Haiku to cache, so the second call shows cached_tokens above 0.
  • The cost of a full run: make verify with a key.

🤖 Generated with Claude Code

claude and others added 3 commits December 2, 2026 22:47
- Route every model call through llm.py (llm.chat); drop temperature,
  fallback models and %pip cells; clear notebook outputs.
- Replace assistant prefill in 05, 07 and 11 with structured output
  (schema=) and plain instructions.
- Add a prompt caching step to 09 (cache_control on a rule book of
  more than 5,000 tokens, read back with Reply.cached_tokens).
- Fix typos, the "final chapter" wording in 10, and lesson names in
  the README so they match the notebooks.
- Rewrite README, AGENTS.md and env.example; pin dependencies with
  floors from today's lock; Python 3.11.
- Makefile titled for this workshop with check and verify targets;
  Docker image and container named after the repo, mount matches
  the working folder.
- Delete unused hints.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ema fix

Claude blocks a schema field named thinking that asks for step by step reasoning.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Param-Harrison
Param-Harrison marked this pull request as ready for review December 2, 2026 22:55
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Param-Harrison
Param-Harrison merged commit 88aeb55 into main Dec 2, 2026
1 check passed
@Param-Harrison
Param-Harrison deleted the revamp/agentic-2026 branch December 2, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants