Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contrib/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@

# Recipes
recipes/search_r1 @SiyunZhao @JiahangXu
recipes/shaper @Control-derek

# Runtime extensions
agentlightning/contrib/shaper @Control-derek
34 changes: 34 additions & 0 deletions contrib/agentlightning/contrib/shaper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SHAPER Runtime Extension

SHAPER evolves two model-external resources around a frozen Agent Lightning
agent: a textual skill and executable context-construction code. It diagnoses
observable rollout transitions, summarizes episode failures into textual
gradients, and performs a sequential skill-then-harness beam search.

The runtime lives in `contrib` because Agent Lightning's core resource union
does not yet have a code-harness resource. SHAPER transports both artifacts as
`PromptTemplate` values. Integrations read harness `template` text as source;
they must never call `PromptTemplate.format()` on that source.

Install Agent Lightning from the repository root and run the SHAPER recipes
from the same checkout:

```bash
python -m pip install -e .
```

Public API:

- `SHAPER`: the two-stage optimization algorithm.
- `SHAPERTraceAdapter`: extracts structured round and episode records.
- `RoundRecord` and `EpisodeMetadata`: the agent-to-algorithm trace contract.
- `PythonHarnessValidator`: static and isolated-process harness validation.
- `emit_round_record` and `emit_episode_metadata`: rollout instrumentation.

Generated harnesses are never executed in the Trainer or simulator process.
Validation and every runtime call use the same restricted isolated interpreter
with finite CPU, memory, output, and wall-time limits. This is fault containment,
not an OS sandbox; use a container or VM for code from an untrusted author.

See [`contrib/recipes/shaper/README.md`](../../../recipes/shaper/README.md)
for VLABench/ESI-Bench environment setup, training, and evaluation commands.
73 changes: 73 additions & 0 deletions contrib/agentlightning/contrib/shaper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright (c) Microsoft. All rights reserved.

"""SHAPER: two-stage skill and context-harness evolution for frozen agents."""

from .algorithm import (
DEFAULT_HARNESS_CONTRACT,
SHAPER,
IncomparableCandidateError,
RolloutInfrastructureError,
SkillValidator,
validate_nonempty_skill,
)
from .prompting import parse_json_object
from .roles import (
ArtifactProposal,
OptimizationStage,
OptimizerRequestContext,
RoleCompleter,
RoleRequest,
SHAPERRoleProtocol,
)
from .sandbox import (
HarnessOutputValidator,
HarnessRuntimeError,
HarnessValidationResult,
PythonHarnessRuntime,
PythonHarnessValidator,
)
from .trace import SHAPERTraceAdapter, emit_episode_metadata, emit_round_record
from .types import (
ArtifactCandidate,
ArtifactStage,
CandidateEvaluation,
EpisodeMetadata,
EpisodeSummary,
EpisodeTrace,
OptimizationEvent,
RoundCritique,
RoundRecord,
)

__all__ = [
"SHAPER",
"DEFAULT_HARNESS_CONTRACT",
"IncomparableCandidateError",
"RolloutInfrastructureError",
"SkillValidator",
"validate_nonempty_skill",
"ArtifactCandidate",
"ArtifactStage",
"CandidateEvaluation",
"EpisodeMetadata",
"EpisodeSummary",
"EpisodeTrace",
"HarnessValidationResult",
"HarnessOutputValidator",
"HarnessRuntimeError",
"OptimizationEvent",
"PythonHarnessValidator",
"PythonHarnessRuntime",
"RoundCritique",
"RoundRecord",
"SHAPERTraceAdapter",
"ArtifactProposal",
"OptimizationStage",
"OptimizerRequestContext",
"RoleCompleter",
"RoleRequest",
"SHAPERRoleProtocol",
"parse_json_object",
"emit_episode_metadata",
"emit_round_record",
]
Loading