ampl-callbacks

ampl-callbacks is a skill for Claude Code, Codex from marcos-dv/ampl-agents. It costs 105 tokens per session (5,703 once invoked), scanned A, original, MIT.

A guide to AMPL solver callbacks, which are Python functions that run inside a solver while it searches for an optimization solution. It uses AMPL Solver Libraries to add rules, cuts, custom stopping conditions, or candidate solutions during that search.

In plain words
What is it for?
Use it for lazy constraints such as subtour elimination, user cuts, Benders or column-generation steps, custom termination rules, and injecting heuristic solutions.
Why use it?
Some algorithms cannot be expressed only in an AMPL model or ordinary solve command. Callbacks let application code affect the solver's search without rebuilding the whole model each time.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is Always-on constraints ([verified solve](../../rules/ampl-verified-solve.md), [model structure](../../rules/ampl-model-structure.md), [session hygiene](../../rul.

Good fit Use it for lazy constraints such as subtour elimination, user cuts, Benders or column-generation steps, custom termination rules, and injecting heuristic solutions.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/marcos-dv/ampl-agents
agentmods
npx agentmods add skills/marcos-dv/ampl-agents/ampl-callbacks

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ampl-callbacks

README.md
[![agentmods](https://agentmods.dev/badge/skills/marcos-dv/ampl-agents/ampl-callbacks/github.svg)](https://agentmods.dev/skills/marcos-dv/ampl-agents/ampl-callbacks)
Your own site
<a href="https://agentmods.dev/skills/marcos-dv/ampl-agents/ampl-callbacks"><img src="https://agentmods.dev/badge/skills/marcos-dv/ampl-agents/ampl-callbacks/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ampl-callbacks

Your own site · 80×15
<a href="https://agentmods.dev/skills/marcos-dv/ampl-agents/ampl-callbacks"><img src="https://agentmods.dev/badge/skills/marcos-dv/ampl-agents/ampl-callbacks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 105 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,703 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00105 $0.05703
Opus 5 $0.00053 $0.02851
Sonnet 5 $0.00021 $0.01141
Haiku 4.5 $0.00011 $0.00570

Measured 8d ago against content hash 0f3071098c57, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

ampl-callbacks scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

IF you have internet access (WebFetch, browser, or curl), FETCH before naming
skills/ampl-callbacks/SKILL.md · 346 lines

How it starts

The opening of the file, as written. The whole thing — 346 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AMPL Callbacks Skill (ampls)

Always-on constraints (verified solve, model structure, session hygiene, verified references) live in rules/ and apply whenever this skill is active.

Mission

ampls (AMPL Solver Libraries) hands you the solver-level model built from an AMPL .nl file, lets you register a callback that runs inside branch and bound, and imports the result back into AMPL. It is Python-only: AMPL script solve; has no callback hook.

Use it for the five things AMPL scripting cannot do:

  1. Lazy constraints: added only when a candidate integer solution violates them (subtour elimination, connectivity, no-goods).
  2. User cuts: strengthen node relaxations (max-flow/min-cut, covers, custom cuts).
  3. Custom termination: stop on a business criterion the solver cannot express.
  4. In-place cuts across iterations: Benders / column generation adding rows or columns to the same matrix instead of re-solving a rebuilt model.
  5. Heuristic solution injection: hand the solver a solution your own code built.

Model structure stays in .mod; only the algorithm is Python.

Challenge the premise first. Most "I need a callback" requests are a solver option (lim:time, mip:gap, lim:nodesampl-tuner) or a reformulation (ampl-modeler). Callbacks cost portability, thread-safety, and debuggability. Recommend the cheapest of the three that works, and say so out loud.


Install and solver support

The roster and versions change, so check them; never quote this file. One amplpy-<solver> package per solver, alongside amplpy:

Package Solver Import alias Check live
amplpy-gurobi Gurobi import amplpy_gurobi as ampls https://pypi.org/project/amplpy-gurobi/
amplpy-cplex CPLEX import amplpy_cplex as ampls https://pypi.org/project/amplpy-cplex/
amplpy-xpress Xpress import amplpy_xpress as ampls https://pypi.org/project/amplpy-xpress/
amplpy-copt COPT import amplpy_copt as ampls https://pypi.org/project/amplpy-copt/

Read the full file on GitHub · 346 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 346 lines · 0 tokens per session scan A 0f3071098c57

Subscribe to this mod's changes

ampl-callbacks is a skill published in the GitHub repository marcos-dv/ampl-agents (10 stars, last pushed 18d ago), licensed MIT. It adds 105 tokens to every session and 5,703 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories