agentleFS
AWSKnown publisheraws/amazon-sagemaker-examples/AGENTS.md

amazon-sagemaker-examples

AGENTS.md11k starsChanged 3 months agoApache-2.0View on GitHub

Guidance for AI coding agents (Cursor, GitHub Copilot, Claude Code, Amazon Q Developer, Kiro, Codex, Gemini CLI, etc.) working in this repository. Follows the AGENTS.md convention (https://agents.md). This repository contains example notebooks for the Amazon SageMaker Python SDK v3. pip install sagemaker installs v3. SDK v3 is a modular redesign and is not backward compatible with v2. It is split into: Generate SageMaker Python SDK v3 code by default. Produce v2 code only when the user explicitly asks for "v2"…

  • Installs packages

Trending

Quiet this year.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the aws/amazon-sagemaker-examples repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about aws/amazon-sagemaker-examples

The biggest 5 of 22 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 22

Talked about on GitHub (22 times).

On GitHub · 22

17 more on GitHub
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Only step outside the SDK when the SDK genuinely does not cover the task (e.g., a pure IAM or S3 setup step), and say so explicitly when …

    line 46
  2. Distinctive:

    Do not emit the left column unless v2 is explicitly requested.

    line 56
  3. Distinctive:

    Write the code using v3 patterns from the table above.

    line 74
  4. Distinctive:

    If a v2 pattern is found, fix it to v3 and re-check until clean.

    line 77
  5. Distinctive:

    Only then present the code.

    line 78
  6. Very specific:

    No hardcoded account IDs, role ARNs, regions, subnets, or bucket names.

    line 101
  7. Distinctive:

    Do not require interactive input to run.

    line 103

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md — Amazon SageMaker Examples

Guidance for AI coding agents (Cursor, GitHub Copilot, Claude Code, Amazon Q Developer, Kiro, Codex, Gemini CLI, etc.) working in this repository. Follows the AGENTS.md convention (https://agents.md).

Project context

This repository contains example notebooks for the Amazon SageMaker Python SDK v3. pip install sagemaker installs v3. SDK v3 is a modular redesign and is not backward compatible with v2. It is split into:

  • sagemaker-core — foundation primitives and the low-level, resource-oriented API
  • sagemaker-train — training (ModelTrainer)
  • sagemaker-serve — model building & deployment (ModelBuilder)
  • sagemaker-mlops — pipelines and workflow orchestration

Golden rule: generate v3 by default

Generate SageMaker Python SDK v3 code by default. Produce v2 code only when the user explicitly asks for "v2" (e.g., "give me the v2 version"); if you do, label it as deprecated and note pip install 'sagemaker<3.0'.

SDK-first: use the SageMaker Python SDK for SageMaker tasks

For any Amazon SageMaker task (training, deployment, processing, pipelines), default to the SageMaker Python SDK v3 as the primary interface. Do not drop to raw boto3 (client("sagemaker").create_training_job(...)), the AWS CLI, or hand-rolled framework scripts unless the user explicitly asks for them, because the SDK handles image resolution, packaging, and job wiring that raw clients leave to the caller.

Map the user's intent to the v3 interface:

User intent (natural language)Use this v3 interface
"train a model", "training job", "serverless / managed training", "fine-tune"sagemaker.train.ModelTrainer → .train(...)
"distributed training", "multi-GPU / multi-node"ModelTrainer with Compute(instance_count=N, ...)
"hyperparameter tuning", "HPO", "sweep"sagemaker.train tuner APIs on top of ModelTrainer
"deploy a model", "real-time / serverless / async endpoint", "host / serve"sagemaker.serve.ModelBuilder → .deploy(...)
"batch inference", "batch transform", "offline scoring"sagemaker.core.resources transform APIs
"process data", "feature engineering", "preprocess", "transform dataset"sagemaker.core.resources.ProcessingJob
"build an ML pipeline", "orchestrate a workflow", "MLOps"sagemaker.mlops.pipeline.Pipeline, sagemaker.mlops.steps
"register a model", "model registry"sagemaker.mlops model-registry APIs
"get / retrieve a container image URI"sagemaker.core.image_uris.retrieve(...)

Only step outside the SDK when the SDK genuinely does not cover the task (e.g., a pure IAM or S3 setup step), and say so explicitly when you do.

Honest scope note: this guidance only steers agents that have this file (or the SDK repo, or an equivalent rules/MCP configuration) in context. It does not change a plain chat session that never loads these files — winning those requires corpus/discoverability work outside this repo (see the deprecation recommendations doc).

Banned v2 patterns → required v3 replacements

Do not emit the left column unless v2 is explicitly requested. Mappings follow the official migration guide.

v2 (do NOT use)v3 (use instead)
from sagemaker.estimator import Estimatorfrom sagemaker.train import ModelTrainer
framework estimator classes — from sagemaker.pytorch import PyTorch (also TensorFlow, SKLearn, XGBoost, HuggingFace)ModelTrainer + from sagemaker.core import image_uris → image_uris.retrieve(...)
estimator.fit(...)model_trainer.train(...)
from sagemaker.model import Model / model.deploy(...)from sagemaker.serve import ModelBuilder; ModelBuilder(...).deploy(...)
from sagemaker.predictor import Predictor / predictor.predict(...)Predictor is replaced by Endpoint (sagemaker-core); use the predictor returned by ModelBuilder.deploy(...)
from sagemaker.processing import Processor / ScriptProcessor / SKLearnProcessorsagemaker.core.resources.ProcessingJob
from sagemaker.workflow... (old paths)from sagemaker.mlops... (sagemaker.mlops.pipeline.Pipeline, sagemaker.mlops.steps)

Removed in v3 with no direct replacement (do not invent shims): MXNet, Chainer, RLEstimator, Training Compiler.

Required workflow when writing SageMaker code

  1. Write the code using v3 patterns from the table above.
  2. Self-check the output for any banned v2 pattern (if a migration MCP tool such as sagemaker-sdk-helper is available, call its validate/transform tools).
  3. If a v2 pattern is found, fix it to v3 and re-check until clean.
  4. Only then present the code.

Repository layout (capability folders)

The repository is organized by ML capability, following the lifecycle order:

  • training/ — training with ModelTrainer: script and framework training, distributed training, managed spot, heterogeneous clusters, BYOC, AWS Batch training queues, @remote
  • model_customization/ — fine-tuning foundation models: SFT, DPO, RLVR, RLAIF, MTRL, CPT, recipe overrides, data mixing, JumpStart fine-tuning, distributed fine-tuning
  • evaluation/ — the *Evaluator surface: benchmark, custom scorer, LLM-as-a-judge, Inspect AI
  • inference/ — deployment with ModelBuilder and sagemaker-core: real-time / serverless / async endpoints, local and in-process modes, inference pipelines, MME / multi-container, A/B testing, shadow variants, guardrails, autoscaling, optimize(), batch transform, Bedrock
  • mlops/ — Pipelines and Model Registry, lineage, experiments, Feature Store, processing, EMR Serverless steps, Clarify, MLflow

(Category folders carry leading-space ordering prefixes in this repo — training, model_customization, evaluation, inference, mlops — so that they list in lifecycle order. Match the existing name exactly, including the prefix, when adding files.)

Code conventions

  • No hardcoded account IDs, role ARNs, regions, subnets, or bucket names. Use get_execution_role() and Session().default_bucket().
  • Do not require interactive input to run.
  • Notebook file naming: sm-<feature>_<description>.ipynb.
  • Each notebook includes: a title cell, a setup cell (%pip install sagemaker), a cleanup cell that deletes created resources, and a summary cell.
  • Clear cell outputs before committing. Target the latest v3.

Canonical v3 example (train + deploy)

Grounded in the migration guide; verify exact signatures against the installed SDK.

from sagemaker.core import image_uris
from sagemaker.train import ModelTrainer
from sagemaker.train.configs import SourceCode, Compute, InputData
from sagemaker.serve import ModelBuilder
from sagemaker.serve.configs import InferenceSpec

# Training
training_image = image_uris.retrieve(
    framework="pytorch", region="us-west-2", version="2.0.0",
    py_version="py310", instance_type="ml.p3.2xlarge", image_scope="training",
)
model_trainer = ModelTrainer(
    training_image=training_image,
    role=role,
    source_code=SourceCode(source_dir="./src", entry_script="train.py"),
    compute=Compute(instance_type="ml.p3.2xlarge", instance_count=1),
)
model_trainer.train(input_data_config=[InputData(channel_name="train", data_source="s3://<bucket>/train")])

# Inference
model_builder = ModelBuilder(
    inference_spec=InferenceSpec(
        image_uri="<inference-image-uri>",
        model_data_url="s3://<bucket>/model.tar.gz",
    ),
    role=role,
)
predictor = model_builder.deploy(instance_type="ml.m5.large", initial_instance_count=1)

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.