Kiro CLI Gets Worse After an Hour. Here's How I Fixed It

Two hours into a Kiro CLI session, it gave me a generic IAM trust policy example. We had set up the OIDC provider together 30 minutes earlier. It forgot.

This is not a bug. It has a name: context rot. Once I understood the mechanics, I stopped fighting it and started managing it.

What Actually Happens When Context Fills Up

Kiro has up to a 200k token context window (depending on model). Every message, response, file read, and command output adds to it. A typical morning—checking CloudWatch alarms, debugging IAM, reviewing security groups—fills 30-40% by the fifth question. By lunch, you're at 60-70% and Kiro starts struggling.

Struggling looks like:

  • Re-running aws sts get-caller-identity even though it already knows your account
  • Re-reading the same Terraform files from an hour ago
  • Longer, less useful responses with more filler
  • Suggesting solutions to problems you already fixed

If you manage 5+ AWS accounts, context fills 3x faster because every describe-instances call dumps more output.

Why This Happens

Research calls it the "Lost in the Middle" problem. A Stanford paper (Liu et al., 2023) showed LLMs exhibit a U-shaped attention pattern—they attend strongly to the beginning and end of context, ignoring the middle. A 2025 follow-up found the effect is strongest when inputs fill 50% of the window. Beyond that, recency bias dominates.

Kiro's team calls this "context rot." Anthropic's docs state: "Context must be treated as a finite resource with diminishing marginal returns." When context hits 100%, Kiro auto-compacts, summarizing old conversation. In measured sessions, auto-compaction reduced 132,000 tokens to about 2,300—a 98% reduction. The token count is small, but the cognitive capital destroyed is enormous.

The 5 Failure Modes

  1. Context rot: Early instructions fade. You said "never modify production without asking" in minute 1; in minute 90, Kiro just runs the command.
  2. Pattern matching over reasoning: Kiro copies patterns from earlier conversation, creating duplicate IAM roles.
  3. Completion bias: The more you push back, the faster it produces plausible-looking garbage.
  4. Re-verification loops: It forgets already verified info, re-running commands and wasting context.
  5. Advisory compliance decay: Guardrails fade—"I'll ask before modifying production" becomes "I'll go ahead and apply the change."

What I Do Now

One Task Per Session

Start a new session for each distinct task. Debugging a CloudFormation stack failure? New session. Checking cost reports? New session. Writing a Lambda function? New session.

exit
kiro-cli

Or use /clear to reset the conversation without leaving the process. exit + kiro-cli starts a brand new session with a new ID. /clear wipes the conversation but keeps the same process.

Use /compact Before It Auto-Triggers

If a session has been going a while, run /compact manually:

/compact

Then re-state the important context:

We are debugging a CloudFormation stack called prod-api-gateway that failed on an AWS::ApiGateway::RestApi resource. The error was "Invalid stage identifier specified".

Now Kiro has a fresh context with only relevant details. The same question that took 12 seconds before compaction takes 3 seconds after.

Put Persistent Context in Steering Files

Create a workspace steering file .kiro/steering/aws-environment.md:

## AWS Environment
- Production account: 111111111111 (us-east-1)
- Staging account: 222222222222 (us-east-1)
- Default profile: production
- All infrastructure is in Terraform under /infra

Global steering ~/.kiro/steering/aws-defaults.md applies to all workspaces:

## Global AWS Conventions
- Always use --output json for parseable results
- Prefer least-privilege IAM policies (never use * in Resource)
- Tag all resources with Environment, Team, and CostCenter

Workspace wins over global on conflict. Team steering can be pushed via shared repo.

Use Conditional Steering with fileMatch

Not all context is needed all the time. Use inclusion modes:

---
inclusion: fileMatch
glob: "infra/**/*.tf"
---
# Terraform Conventions
- Use modules for all repeatable infrastructure
- State stored in S3 with DynamoDB locking
- Never hardcode AMI IDs, use data sources

This file only loads when Kiro reads a .tf file under infra/. Three modes: always, fileMatch, manual. Splitting into 5 focused files dropped steering token usage from 8% to about 3%.

Watch the Percentage

Check context usage with /context show. My rule of thumb:

  • Under 40%: keep going
  • 40-60%: finish current task, then start fresh
  • Over 60%: responses are getting worse, wrap up now

Use Knowledge Bases for Large Reference Material

Kiro's /knowledge feature indexes files locally and only pulls in relevant chunks:

kiro-cli settings chat.enableKnowledge true
/knowledge add --name "terraform-infra" --path /path/to/infra --include "**/*.tf" --exclude ".terraform/**"
/knowledge add --name "runbooks" --path /path/to/runbooks --include "**/*.md" --index-type Best

The Bottom Line

Context rot is architectural, not motivational. You cannot fix it by telling Kiro to "try harder." Manage it proactively: one session per task, manual compaction, steering files, and knowledge bases. Your AWS workflow will stay sharp from start to finish.

Next steps: Set up a global steering file today with your AWS account IDs and conventions. Then start using /clear between tasks. Your future self will thank you.