Improve agents with self-improvement routines
Getting an agent to production is not the finish line. Agents meet new situations, skills change underneath them, and permissions pile up. Left alone, an agent drifts: it fails on the same step again and again, burns tokens on loops, and holds access it no longer needs.
Self-improvement routines are scheduled workflows that review how your agents actually behave and propose improvements. They close the feedback loop between what agents do in production and the assets that shape them, making each agent a little better and cheaper over time, with a human approving every change.
Why you need self-improvement routines
Today, once an agent reaches production, nobody looks at how it behaves unless something breaks. A tool call is denied, the agent retries, works around it and eventually succeeds at a higher cost. Permissions granted for one task stay forever.
With self-improvement routines, scheduled workflows in Port sample recent sessions, find patterns, trace each one to the registry asset behind it and propose a fix to its owner. Every change is approved by a human before it is applied.
| Pain point | Without Port | With Port |
|---|---|---|
| Repeated, costly failures | The same failures repeat every day, and loops, retries and workarounds make agents more expensive each month with no added value. | Routines surface repeated failures and fix their cause, removing loops and retries and lowering cost per session. |
| Growing blast radius | Access granted for one task is never removed, so each agent's potential damage keeps growing. | Unused permissions, skills and tools are trimmed regularly, so agents keep only the access they use. |
| Fixes that stay local | A fix improves one agent, while every other agent using the same skill keeps failing. | Fixes go to the shared skill, MCP server or permission, so every agent that uses it improves at once. |
Agent dreaming
Anthropic uses agent dreaming to improve an agent's memory between sessions: the agent reviews what happened and consolidates what it learned, the way people do while they sleep.
Better memory is not always enough. Many failures come from the assets around the agent, such as a skill that contradicts the system prompt or the agent's memory, or a tool the agent needs but doesn't have. Memory alone can't fix those, and every other agent using the same assets keeps hitting them.
AgentOps applies the same framework to the entire registry. Because Port knows which skills, MCP servers, prompts and permissions each agent depends on, a dreaming routine can trace a failure to the shared asset behind it and fix that asset, so every agent that uses it improves.
A registry-level dreaming routine runs on a schedule, for example once a day per agent:
- Sample sessions - take a sample of the agent's sessions from the last day.
- Find repeated failures - look for patterns that recur across sessions, such as:
- Tool calls denied because the agent lacks a permission.
- Loops on the same step of a skill.
- Contradictory assumptions between the agent's instructions and its skills.
- Repeated workarounds that cost extra tokens.
- Trace the root asset - link each pattern to the asset behind it: the system prompt, a skill, an MCP server or a permission.
- Propose a fix - draft a concrete change, such as a clearer skill step, a missing tool on a logical MCP server, or a permission request.
- Ask the owner - send the proposal to the asset's owner, who approves, edits or rejects it.
- Apply through a golden path - approved fixes go through the same golden paths as any other change, so they are versioned and audited.

Before a fix to a shared asset is approved, the routine uses the dependency graph to show the owner every other agent that will be affected.
Minimize blast radius
Agents collect access over time, and a permission requested for one task often stays forever. A blast-radius routine follows the same pattern as dreaming, usually on a longer cadence such as once a week per agent. Instead of looking for what an agent is missing, it looks for what the agent holds but doesn't use:
- Compare the permissions, skills and tools the agent holds with the ones it actually used during the period.
- List what went unused.
- Propose removing it, with approval from the agent's owner.
Each run makes the agent's blast-radius score a little better, with no change to what the agent actually does.
Where session data comes from
Routines need data about what agents actually did. Port can bring it into the Context Lake from:
- Agent platforms - session and run data from platforms such as Claude managed agents, AWS Bedrock and Azure AI Foundry.
- Port AI - every interaction with Port's own agents is recorded as an AI invocation.
- AI gateways - usage, cost and latency per key and per agent. See AgentOps and AI gateways.
Track improvement over time
Routines should show their value. Track a few metrics per agent before and after each approved change:
- Failure rate - how often sessions hit a repeated failure.
- Tokens per session - what each session costs.
- Permissions held versus used - how much unused access remains.
- Fixes proposed versus approved - how useful the routine's proposals are.
These metrics also feed ROI measurement, so you can see how optimization changes the value of each asset.