Environment and Skills
Run commands on the environment
Not everything needs to go through the agent loop. InvokeAgentRuntimeCommand gives you direct shell access to the harness microVM: deterministic command execution with no model reasoning, no token cost, no ambiguity.
Use it to:
-
Run deterministic pre-invocation or post-invocation scripts.
-
Prepare the environment before an invocation: clone a repo, install dependencies, copy input files.
-
Act on what the agent produced: run tests, commit and push, extract build artifacts.
-
Inspect the VM during development:
ls,cat,env,python --versionwithout a round trip through the model.
Example
See InvokeAgentRuntimeCommand API for details.
Note
Commands run as root (uid 0) within the microVM. This is analogous to root on your own EC2 instance - the IAM permission is the access gate, not the in-VM privilege level. If your Dockerfile includes a USER directive, it applies to the agent process only (the container’s main entrypoint). InvokeAgentRuntimeCommand runs at a higher privilege level for operational purposes, similar to how docker exec defaults to root even when the container runs as a non-root user. See Execute shell commands in AgentCore Runtime sessions for full details on security, error handling, and best practices.
Custom environment (container images)
The base environment includes Python and bash, enough for most tasks. When you need more, package your source code, dependencies, runtimes, and tools into a container image, push it to ECR, and reference it on the harness. Your agent runs in that exact environment. Pair custom images with InvokeAgentRuntimeCommand for session-specific setup that varies per invocation.
Container images must be built for the linux/arm64 platform.
The harness overrides your container’s ENTRYPOINT and CMD to keep it running as an environment. Your installed software, filesystem, and environment variables are available to the agent; your container’s startup command is not executed. If you need a background process (such as a dev server), start it via InvokeAgentRuntimeCommand after the session begins.
Example
Environment variables
Set environment variables that are passed to the runtime container. Environment variables are available to the agent and any custom container running in the session.
Example
Agent Skills
Agent Skillsskills parameter on the harness or at invoke time is a pointer to a path inside the environment - it does not upload or install the skill.
Getting skills into the environment
Bake into the container image - include the skill directory in your custom image at a known path (e.g. .agents/skills/xlsx). Available to all invocations automatically. This is the recommended approach for production.
Install at session start - use InvokeAgentRuntimeCommand to install skills after the session begins, before invoking the agent:
agentcore invoke --exec --harness my-agent --session-id "$(uuidgen)" \ "npx @anthropic-ai/agent-skills add xlsx github"
Pointing the harness at installed skills
Example
Related topics
-
Connect to tools - connect MCP servers, Gateway, Browser, and Code Interpreter
-
Persist memory and filesystem - persist conversations and files across sessions
-
Security and access controls - execution roles and VPC configuration