8.4: Advance AI Agents Advice

The ADAPT WeBWorK Handbook · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    Read aloud

    How

    Speed: 1×
    Light up
    Highlight

    Symbols: Mulberry Symbols, © 2018–2026 Steve Lee, CC BY-SA 4.0 (licence, the set), the site's own copies.

    From LibreTexts, under CC BY 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    8.4: Advance AI Agents Advice

    The quality of the problem an agent produces depends on how clearly you communicate what you want. A vague prompt produces a generic question; a detailed prompt produces a polished, randomized problem ready for students. The amino acid isoelectric point problem from the video demonstrates every principle on this page.

    Set boundaries before starting

    Before you give the agent a biology prompt, set up a clean environment so it stays focused on your problem instead of wandering through unrelated files.

    • Start with an empty project directory so the agent has a clean workspace. A folder cluttered with old drafts and unrelated code invites the agent to copy patterns that may not apply.
    • Tell the agent not to search your filesystem for example files. A simple instruction like "all the documents you need are in the skill" prevents it from finding unrelated .pg files and copying bad patterns.
    • Keep the working directory simple: one .pg file, the knowledge documents, and nothing else. The fewer distractions the agent has, the better it follows your instructions.
    • Claude Code runs locally with full filesystem access, so setting clear boundaries matters. Codex runs in a cloud sandbox with limited access by default, but you should still keep its workspace clean.

    Write detailed prompts

    A good prompt tells the agent exactly what the problem should do. The table below lists the elements that produce the best results, with examples drawn from the amino acid isoelectric point problem in the video.

    Prompt elements and examples from the amino acid isoelectric point video.
    Prompt element Example from video
    Topic and learning objective "amino acid isoelectric points"
    Number of parts "write a two-part question"
    Interaction types "part 1: select the charge state, part 2: calculate the pI"
    Randomization requirements "randomize the pKa values between versions so students cannot copy answers"
    Visual and display preferences "include a table showing the amino acid with its pKa values"
    Constraints "use a hypothetical amino acid with three pKa values"
    Color and formatting "color the charged groups: red for negative, blue for positive, gray for neutral"

    Be patient

    Complex problems take 15 to 20 minutes for the agent to write and debug. This is normal. The agent cycles through writing code, rendering it, reading error messages, and fixing problems. Each cycle brings the problem closer to working correctly.

    The agent asking clarifying questions is a sign it is working carefully, not a sign of failure. Answer its questions and let it continue. Do not interrupt the agent mid-cycle. Let it finish its render-test-fix loop before giving new instructions. Breaking into the loop disrupts the agent's context and often forces it to start over.

    It is better for the agent to sit there and struggle getting the problem correct than for you to sit there and struggle. You brought the biology expertise; let the agent handle the code.

    Refine iteratively

    Do not try to get a perfect problem on the first attempt. Use a three-pass approach that separates functionality from appearance from polish.

    1. Get it working. The problem renders without errors and accepts correct answers. Do not worry about appearance yet. A working skeleton is always the first milestone.
    2. Improve presentation. Add color, adjust layout, and improve readability. In the video, the instructor asked the agent to color the charge states after the basic problem was already working.
    3. Accessibility and polish. Ensure color-blind safety (avoid red-green pairs), test with multiple random seeds, and verify all variants produce valid questions.

    Accessibility and color

    Color makes problems easier to read, but roughly 8 percent of males have red-green color blindness. Follow these guidelines so your problems work for everyone.

    • Avoid red-green color pairs. Use high-contrast pairs instead: blue and orange, or navy and gold. The video mentions that "Bears colors" work well for contrast.
    • Use gray for neutral or uncharged elements so positive and negative charges stand out clearly.
    • Always pair color with another visual cue such as bold weight, font size, or a background highlight. The meaning must survive without color so that colorblind users and screen readers can still distinguish the elements.

    See Text Coloring and Emphasis for CSS techniques and the recommended color palette.

    Worked example: amino acid isoelectric point

    The amino acid isoelectric point problem from the video illustrates the full workflow from prompt to finished problem. It also shows why detailed prompts matter and how iterative refinement produces a polished result.

    The teaching moment. The instructor described a familiar classroom experience: projecting a titration curve and seeing 50 glazed eyes looking back. The curve was accurate, but students could not connect the visual to the underlying concept. This problem turns that confusing lecture slide into an interactive exercise where students work through the logic step by step.

    The prompt. The instructor asked for a two-part question. Part 1: given a hypothetical amino acid with three randomized pKa values, identify which charge state has zero net charge. Part 2: calculate the isoelectric point (pI) by averaging the two pKa values that bracket the neutral state. The prompt specified randomized pKa values so that each student version would be different.

    The process. The agent took approximately 15 minutes. It asked clarifying questions about the display format, created the .pg file, rendered it against the local PG renderer, found seed-related bugs, and fixed them automatically. The instructor did not need to touch the code at any point during this cycle.

    Refinement. After the basic problem worked, the instructor asked for color. The agent added blue for positive charges and red for negative charges. A follow-up request changed neutral groups to gray so the charged groups stood out more clearly. Side chains were colored separately from backbone groups. Each refinement was a short prompt followed by another render-test-fix cycle.

    The result. A fully randomized two-part problem where pKa values vary between student versions. Students identify the zero-charge state and calculate the pI, practicing the concept that used to produce glazed eyes. As the instructor put it: "I don't need to know how to program."

    For techniques used in this problem, see Advanced Randomization and Testing Randomization and Edge Cases.

    Common pitfalls

    These mistakes appear repeatedly when instructors first work with AI agents. Most are easy to prevent once you know to watch for them.

    Common pitfalls when using AI agents for WeBWorK and how to prevent them.
    Pitfall What happens Prevention
    No knowledge documents Agent writes standard Perl that fails in the PG sandbox because it does not know PG-specific conventions Install the webwork-writer skill before starting (see Knowledge Documents for AI Agents)
    Filesystem searching Agent finds unrelated .pg files on your system and copies outdated or incorrect patterns Tell the agent to use only the provided documents and keep the working directory clean
    Skipping the renderer Agent writes code it has never tested, producing problems that look plausible but fail when rendered Connect the agent to a local renderer before starting (see Connecting AI Agents to the PG Renderer)
    Not re-reading docs Agent forgets a rule mid-session and introduces a pattern the knowledge documents explicitly warn against Prompt the agent: "re-read the common mistakes document" when you see suspicious output
    Impatient intervention You interrupt the render-fix loop and break the agent's context, often forcing it to start over Let the agent finish its current cycle before giving new instructions
    No seed testing Problem works for seed 1 but breaks on other seeds because a randomized value hits an edge case Require the agent to test with at least 3 random seeds before declaring the problem done
    Deprecated patterns Agent uses legacy PG syntax that produces warnings or fails on current PG versions Ensure knowledge documents specify PG 2.17 rules and current macro names

    Scaling to many problems

    Once you have one working problem, you can produce more efficiently by reusing what already works.

    • Reuse a working problem as a template. Give the agent an existing .pg file and ask for a variation on the same topic or a parallel question for a different biological concept.
    • Use batch rendering to test many files at once instead of rendering them one by one. See Scripting and Automation for how to set up batch workflows.
    • Run the QA checklist on every problem before publishing, not just the first one in a set. See QA Checklist for the full list.

    Apply it today

    • Write a detailed prompt for one biology question following the prompt element table above. Include the topic, the number of parts, the interaction types, and what should be randomized.
    • Let the agent work through the full write-render-fix cycle without interrupting. Observe how it self-corrects and how long the process takes.
    • Test the finished problem with at least 5 random seeds to verify that every variant produces a valid question.
    • Run the QA checklist from QA Checklist before publishing the problem to students.

    This page titled 8.4: Advance AI Agents Advice was last modified on Fri, 27 Feb 2026 14:55:36 GMT and is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Neil R. Voss.