Skip to main content
Glama

Render a graded coding exercise

render_exercise
Read-only

Render a graded coding exercise as an interactive widget. Learners use the editor and Submit to run hidden tests, and failed attempts are returned to the chat for targeted feedback.

Instructions

Render a graded coding exercise as an interactive widget in the conversation.

The learner gets a lesson pane and an editor pane with Run and Submit. Submit executes your hidden tests against their code in the browser and shows a pass/fail verdict. On failure they can push their exact code and the exact error back into this conversation with one click — that is the point of this tool, so write tests whose failures are informative.

Call this when someone asks to learn, practise or be quizzed on Python, JavaScript, TypeScript or SQL. Author everything yourself: there is no curriculum behind this tool.

Rules for good exercises:

  • One concept, one answer, solvable in a few minutes.

  • 'task_md' must state exactly what is wanted: the function and signature the tests call, or for SQL which columns come back and whether row order matters.

  • 'starter_code' contains the skeleton and a placeholder, never the answer.

  • 'tests' are hidden until submission, and their form differs by language — see the field description. Test only what 'task_md' actually asked for; a test the learner could not have anticipated is a bug, not a difficulty.

  • SQL exercises also need 'seed'. The learner sees the schema, not your reference query.

  • Hints escalate: first a nudge, last one close to the answer.

When the learner is stuck or posts a failed attempt back into the chat, explain what THEIR code did wrong and point at the next hint. Do not hand over the solution on request; that is what the gated "show solution" button in the widget is for. If they insist after several genuine attempts, walk them through it rather than pasting it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
seedNoSQL only, and required for sql: CREATE TABLE statements plus INSERTs, run before anything else on a fresh in-memory database. Keep it small — a handful of rows chosen so a wrong query gives a visibly wrong answer, including at least one edge case (a NULL, a tie, an empty group). The widget shows the learner the resulting table names, columns and row counts, so this is not hidden; the reference answer in 'tests' is.
hintsNoEscalating hints, nudge first and near-answer last. Revealed one at a time: the first is free, each later one unlocks after another failed submission.
testsYesThe hidden grader, never shown before submission. Its form depends on the language. python: plain `assert` statements, at least three, one an edge case. javascript/typescript: `assert(cond, msg)`, `assertEquals(actual, expected)` and `assertDeepEquals(actual, expected)` are in scope; at least three assertions. Tests run in the same scope as the learner's code, so they can call whatever it defines. TypeScript tests may be typed; the types are erased before running. sql: a *reference answer written as SQL* — not expected rows. It runs against its own copy of the seeded database and the learner's result set is compared to it, so write the query you would accept as correct. Row order is enforced only if the reference has an ORDER BY; force it either way with a first line of `-- ordered` or `-- unordered`. For an INSERT/UPDATE/DELETE exercise, write the equivalent statements and the resulting table contents are compared instead.
titleYesShort exercise title, e.g. 'f-strings: formatting numbers'.
task_mdYesMarkdown. Exactly what the learner must produce. For python/javascript/typescript, name the required function and its signature. For sql, say which columns to return, in what order, and whether row order matters.
languageYesRuntime for the exercise. 'python' runs on Pyodide; 'javascript' and 'typescript' in a sandboxed worker; 'sql' on SQLite. All four execute in the learner's browser.
solutionNoReference solution. Kept hidden by the widget until three failed submissions.
lesson_mdYesMarkdown. The concept plus one worked example. Keep it short — a screenful, not a chapter.
starter_codeYesWhat the editor opens with. Include the signature and a '# your code here' placeholder, never the answer. For sql, a comment and the skeleton of a statement (e.g. 'SELECT ... FROM orders').

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description is highly transparent about the tool's behavior and implications. It explains the submission flow ('Submit executes your hidden tests against their code in the browser and shows a pass/fail verdict'), the failure recovery mechanism (one-click push of code and error back into the conversation), and the purpose of the tests ('write tests whose failures are informative'). It also discloses the policy around solutions: 'Do not hand over the solution on request; that is what the gated "show solution" button in the widget is for.' This enriches the readOnlyHint annotation by clarifying what side effects occur (none external) and what the widget does. No contradiction with annotations; in fact, it reinforces that the tool does not mutate external state.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is longer than average, but it is well-structured with a clear opening purpose, followed by contextual usage, then a bulleted list of rules for good exercises, and behavioral guidance. The organization makes it easy to scan, and the essential action ('Render a graded coding exercise') is front-loaded. While some sentences could be tightened (e.g., merging overlapping rules), the length is justified given the complexity of the tool and the need to communicate subtle constraints. It earns a 4, falling short of 5 because it is not maximally concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (9 parameters, language-specific behaviors, hidden tests, SQL seeding, hint escalation) and the lack of an output schema, the description is remarkably complete. It explains the widget's interactive behavior, what happens on submission, the policy on solutions, and the exact authoring requirements for each language. It also addresses edge cases like SQL row order and hidden tests. The description covers enough for an agent to call the tool correctly without needing additional context. No essential information is missing; the only minor lack is an explicit indication of what the tool returns (since there is no output schema), but the description implies the widget is returned.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already covers all parameters with descriptions (100% coverage), so the baseline is 3. The description adds meaningful value beyond the schema by providing concrete authoring rules for several parameters: e.g., 'task_md must state exactly what is wanted', 'starter_code contains the skeleton and a placeholder, never the answer', 'tests are hidden until submission' with language-specific guidance, and 'SQL exercises also need seed' with details on edge cases. These are not just restatements; they give the agent actionable instructions that the schema does not. The description also advises on hint escalation, which maps to the 'hints' parameter. This lifts the score to 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a clear, specific statement of what the tool does: 'Render a graded coding exercise as an interactive widget in the conversation.' It names the resource (graded coding exercise), the action (render as interactive widget), and the context (conversation). It goes on to describe the learner experience (lesson pane, editor pane, Run/Submit) without ambiguity. Since there are no sibling tools, differentiation is not needed, but the purpose is unmistakable.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to call the tool: 'Call this when someone asks to learn, practise or be quizzed on Python, JavaScript, TypeScript or SQL.' It also provides clear non-usage guidance by noting 'there is no curriculum behind this tool' and advising the agent to author everything itself. While it does not name an alternative tool (since none exist), it gives enough context on triggers and expectations. A slightly higher score is withheld because it does not explicitly mention scenarios where the tool should NOT be used (e.g., when a non-supported language is requested), though the language enum implicitly covers that.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools