1. Analysis Report Agent
We will build an agent that analyzes data and produces a slide (PPTX) report. The uv and authentication setup is the same as in 3. Create an Agent with the SDK; we will create a new project for this page and work from there.
On this page, we will use the following Managed Agents features for the first time.
| Feature | Role |
|---|---|
Built-in tools (agent_toolset) | A set of tools for running bash, file operations, web search, and more inside the sandbox |
Environment packages | Configuration that pre-installs apt, pip, and npm packages into the sandbox |
Skills (skills) | A mechanism for teaching the agent specialized workflows such as document creation |
| Session outputs | A mechanism for downloading files the agent saved to /mnt/session/outputs/ to your local machine |
1. Create a Project
Section titled “1. Create a Project”Create a project, move into its folder, and install the Claude SDK.
uv init report-agentcd report-agentuv add anthropic2. Create the Resources
Section titled “2. Create the Resources”-
Create
setup_report.pyin the project folder and save the following content.setup_report.py import jsonfrom anthropic import Anthropicclient = Anthropic()################################ 1. Create the environment (pre-install the pptx skill's dependencies)###############################environment = client.beta.environments.create(name="Report-environment-adv",config={"type": "cloud","packages": {"apt": ["libreoffice-impress", "poppler-utils", "fonts-noto-cjk"],"pip": ["markitdown[pptx]", "Pillow"],"npm": ["pptxgenjs"],},"networking": {"type": "unrestricted"},},)print(f"environment: {environment.id}")################################ 2. Create the agent (full built-in toolset + pptx skill)###############################agent = client.beta.agents.create(name="Report Agent ADV",model="claude-sonnet-5",description="An agent that performs data analysis and creates slide reports.",system="You are a data analysis and report creation assistant. Use the sandbox's bash and Python for analysis, and follow the pptx skill for slide creation. Always save deliverables to /mnt/session/outputs/.",tools=[{"type": "agent_toolset_20260401", "default_config": {"enabled": True}}],skills=[{"type": "anthropic", "skill_id": "pptx"}],)print(f"agent: {agent.id}")with open("ids_report.json", "w") as f:json.dump({"environment_id": environment.id, "agent_id": agent.id}, f, indent=2)print("Saved IDs to ids_report.json")There are three key points in this configuration.
packages— Pre-installs the dependencies required by the pptx skill definition (LibreOffice, Poppler, markitdown, pptxgenjs) plus Japanese fonts. apt, cargo, gem, go, npm, and pip are supported, and packages are cached across sessions that use the same environmentagent_toolset_20260401— The full set of built-in tools: bash, read/write/edit, glob/grep, and web search/fetch. Unlike the MCP tools we used so far, these run inside the sandboxskills— Anthropic’s prebuilt skills (pptx, plusxlsx,docx, andpdf) can be used simply by specifying askill_id
-
Run the script.
Terminal window uv run setup_report.py
3. Have the Agent Create a Report
Section titled “3. Have the Agent Create a Report”-
Create
report.pyin the project folder and save the following content.report.py import jsonimport pathlibfrom anthropic import Anthropicclient = Anthropic()with open("ids_report.json") as f:ids = json.load(f)# Create a sessionsession = client.beta.sessions.create(agent=ids["agent_id"],environment_id=ids["environment_id"],)print(f"session: {session.id}")# Open the stream before sending the taskstream = client.beta.sessions.events.stream(session_id=session.id)client.beta.sessions.events.send(session.id,events=[{"type": "user.message","content": [{"type": "text","text": ("Create a CSV of one year of monthly sales data (units sold and revenue) ""for a fictional takoyaki shop, and analyze the trends. Then turn the ""results into a 3-slide PPTX report consisting of a title slide, a sales ""trend chart, and an analysis summary, and save it to ""/mnt/session/outputs/report.pptx."),}],}],)print("Task sent. This will take a few minutes to complete...\n")for event in stream:if event.type == "agent.tool_use":print(f"[tool: {event.name}]")elif event.type == "agent.message":for block in event.content:if block.type == "text":print(block.text)elif event.type == "session.status_idle":if event.stop_reason.type != "requires_action":breakelif event.type == "session.status_terminated":breakstream.close()# Download the deliverablesprint("\nChecking the deliverables...")files = client.beta.files.list(scope_id=session.id,betas=["managed-agents-2026-04-01"],)for f in files.data:print(f"- {f.filename} ({f.size_bytes} bytes)")content = client.beta.files.download(f.id)out = pathlib.Path(f.filename).namecontent.write_to_file(out)print(f" -> saved to {out}")The final block downloads the deliverables. Files the agent saved to
/mnt/session/outputs/can be listed and downloaded with the Files API by passing the session ID asscope_id. -
Run the script. The first run takes about 5-10 minutes for sandbox preparation (installing LibreOffice and other packages) and slide creation.
Terminal window uv run report.pysession: sesn_016pxZpFV5ny8Wj14fU2wVgDTask sent. This will take a few minutes to complete...[tool: bash]The data looks good. Next, I will run the analysis.[tool: bash]pptxgenjs is available. I will create the slides with a color palette that suits a takoyaki shop.[tool: write][tool: bash]Running content QA and visual QA....I will fix two issues: the line chart interpolation (lineSmooth) exaggerates the data, and the gold text on slide 3 has weak contrast.[tool: edit]...I have created the following deliverables....Checking the deliverables...- report.pptx (26240 bytes)-> saved to report.pptx- takoyaki_monthly_sales.csv (344 bytes)-> saved to takoyaki_monthly_sales.csv -
Open the downloaded
report.pptxin PowerPoint or a similar app and check the result.
Summary
Section titled “Summary”- The environment’s
packagessetting lets you pre-install apt, pip, and npm packages into the sandbox (cached across sessions that use the same environment). - Enabling the built-in tools (
agent_toolset) lets the agent run bash and file operations inside the sandbox. - Skills let you teach the agent specialized workflows like slide creation just by specifying a
skill_id. - Deliverables the agent saved to
/mnt/session/outputs/can be listed and downloaded via the Files API by passing the session ID asscope_id.
Great work! Please share your thoughts so far in a post on X.
Share your thoughts on X