Skip to content

docs(harness): sharpen overview and session pages#18151

Merged
abhiaiyer91 merged 16 commits into
mainfrom
astonishing-oval
Jun 18, 2026
Merged

docs(harness): sharpen overview and session pages#18151
abhiaiyer91 merged 16 commits into
mainfrom
astonishing-oval

Conversation

@abhiaiyer91

@abhiaiyer91 abhiaiyer91 commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Improves the Harness documentation so it explains what a harness is and what it's for before diving into APIs.

Harness overview

  • Lead with a clear definition of an agent harness: the runtime that wraps a model and governs its behavior, distinct from the framework you build an agent from.
  • Rewrite the "What you can build" section to be outcome-driven — each item maps a concrete result to the capability and doc page that delivers it.
  • Reframe "When to use the Harness" so it no longer implies the Agent class is only for one-shot calls; the Harness is positioned as an opinionated default for collaborative-session apps.
  • Add missing reference links: model router, signals, the events reference, and observational memory.

Session page

  • Link the first mention of Session to the Session reference page.
  • Replace the Harness-vs-Session comparison table with a high-level description of the Session's scope of responsibilities.

Test plan

  • Docs-only change. Verified every internal link resolves to an existing page or in-page anchor, and confirmed the Harness Quickstart code matches the current Harness API (constructor config, mode shape, and the init / selectOrCreateThread / sendMessage / subscribe methods) in packages/core/src/harness.

ELI5 Explanation

This PR makes the Harness docs easier to understand by first explaining, in plain terms, what the Harness is (a runtime that controls how a model behaves) and what you can build with it. It also rewrites the Session and Modes pages so readers know exactly what each thing tracks/controls, and it adds missing links to related references.

Overview Changes

docs/src/content/en/docs/harness/overview.mdx

  • Sharper definition up front: Replaces earlier wording with a clear explanation that the Harness is a runtime that wraps a model and governs its behavior (separate from the agent/framework used to build an agent).
  • Outcome-driven “What you can build”: Rewrites the section to map concrete results to capabilities, including:
    • Persistent threads/state management
    • Tool-approval gating
    • Modes on a single thread
    • Runtime model switching
    • Subagents
    • Live UI/event driving
    • Long-lived autonomous agents
  • Reframed “When to use the Harness”: Positions the Harness as an opinionated default for collaborative-session apps, clarifying that Agent is better suited for full control or one-shot calls.
  • Reference link gaps filled: Adds missing links for the model router, signals, the events reference (including HarnessDisplayState), and observational memory.

Session Page Changes

docs/src/content/en/docs/harness/session.mdx

  • Removed “Harness vs. Session” comparison: Replaces it with a clearer, high-level description of the Session’s scope.
  • Better Session framing: Adds “What the Session tracks,” describing Session as per-conversation live state and breaking down Session sub-objects in conversation-building order.
  • Follow-ups clarified: Explains that follow-ups added during an active run are queued on session.followUps, and introduces mid-run redirection via harness.steer({ content }) (signals-based).
  • Display state rewritten and concretized: Updates session.displayState to a reducer-maintained snapshot that folds harness events into a single HarnessDisplayState object, including guidance to subscribe and render when display_state_changed fires.
  • First Session mention linked: The initial use of Session on the page now links to the Session reference.

Modes Page Changes

docs/src/content/en/docs/harness/modes.mdx

  • What a mode is (and that it’s required): Adds a clear explanation that modes must be provided and what they consist of (e.g., instructions, tools, model).
  • Startup/selection behavior clarified: Documents what happens when modes are empty and how the default mode is chosen (via metadata like default / defaultModeId, or the first mode).
  • Querying modes clarified: Expands guidance that the Harness owns the mode catalog while the Session tracks the active mode, referencing harness.listModes(), harness.session.mode.get(), and harness.session.mode.resolve().

Testing / Validation Notes

  • Internal links were verified to resolve correctly.
  • Harness Quickstart code was confirmed to match the current Harness API in packages/core/src/harness (constructor config, mode shape, and init, selectOrCreateThread, sendMessage, subscribe).
  • Changes are documentation-only.

Reframe the Harness overview so it leads with what an agent harness is
(a runtime that wraps a model) versus the framework you build an agent
from. Make the capabilities outcome-driven, position the Harness as an
opinionated default for collaborative sessions instead of implying the
Agent class is only for one-shot calls, and add missing reference links
(model router, signals, events, observational memory).

On the Session page, link the first mention to the Session reference and
replace the Harness-vs-Session comparison with a high-level description
of the Session's scope of responsibilities.

Co-Authored-By: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
@changeset-bot

changeset-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a83ca69

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mastra-docs-1.x Ready Ready Preview, Comment Jun 18, 2026 3:06pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
mastra-playground-ui Skipped Skipped Jun 18, 2026 3:06pm

Request Review

@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Jun 18, 2026
@dane-ai-mastra dane-ai-mastra Bot added the complexity: low Low-complexity PR label Jun 18, 2026
@dane-ai-mastra

dane-ai-mastra Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

PR triage

Linked issue check skipped for core contributor @abhiaiyer91.


PR complexity score

Factor Value Score impact
Files changed 6 +12
Lines changed 144 +6
Author merged PRs 633 -20
Test files changed No -0
Final score -2

Applied label: complexity: low


Changed test gate

No changed test files were detected.

Label: tests: no tests added

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@abhiaiyer91, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 24 minutes and 5 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 85e2a6d3-1f01-49c9-919b-617765139b66

📥 Commits

Reviewing files that changed from the base of the PR and between f2ce682 and a83ca69.

📒 Files selected for processing (6)
  • docs/src/content/en/docs/harness/modes.mdx
  • docs/src/content/en/docs/harness/overview.mdx
  • docs/src/content/en/docs/harness/session.mdx
  • docs/src/content/en/docs/harness/subagents.mdx
  • docs/src/content/en/docs/harness/threads-and-state.mdx
  • docs/src/content/en/docs/harness/tool-approvals.mdx

Walkthrough

Documentation-only update to three Harness MDX pages. The overview replaces the session-controller framing and application table with capability bullets and Agent-vs-Harness guidance. The modes page adds constraint/startup rules and clarifies mode catalog vs. active mode access. The session page removes the comparison table in favor of a "What the Session tracks" breakdown and expands the Follow-ups and Display state sections with harness.steer and event-driven re-rendering guidance.

Changes

Harness & Session documentation updates

Layer / File(s) Summary
Harness overview rewrite
docs/src/content/en/docs/harness/overview.mdx
Replaces the session-controller description and application table with updated "What you can build" bullets covering threads/state, approvals, modes, model switching, subagents, and event-driven UI; adds a paragraph contrasting Agent versus Harness usage for collaborative sessions; and expands "Key capabilities" with references to the model router, signals, event system/HarnessDisplayState snapshots, and observational memory docs.
Modes documentation rewrite
docs/src/content/en/docs/harness/modes.mdx
Redefines modes as layered behaviors on a shared backing agent with one active mode and thread/state carryover across switches; adds constraints on the modes array requirement and startup mode selection rules (metadata.default, defaultModeId, or first mode); and clarifies that the Harness provides the full mode catalog while the Session tracks the active mode.
Session page rewrite
docs/src/content/en/docs/harness/session.mdx
Removes the "Harness vs. Session" comparison table and rewrites the opening as a "What the Session tracks" section with an ordered sub-object breakdown; extends the "Follow-ups" section to cover queuing on session.followUps during active runs and mid-run redirection via harness.steer({ content }); and expands "Display state" to explain session.displayState as a reducer-maintained HarnessDisplayState snapshot, enumerate its fields, and show the re-render pattern on display_state_changed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • mastra-ai/mastra#17290: Adds the harness v1 EventEmitter and harness.subscribe() API that enables the event subscription and display-state snapshot system now documented in this PR.
  • mastra-ai/mastra#18008: Eliminates per-mode agent forking and resolves mode instructions/tools at call time to keep signal providers connected, which aligns with this PR's documentation of modes as layered behaviors on a shared backing agent.
  • mastra-ai/mastra#18032: Concurrently updates the same Harness documentation pages to describe modes and session concepts in aligned terms.

Suggested labels

complexity: medium

Suggested reviewers

  • wardpeet
  • LekoArts
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs(harness): sharpen overview and session pages' is concise (49 characters), uses imperative mood, follows proper capitalization, and accurately describes the main documentation improvements to the Harness overview and session pages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch astonishing-oval

Comment @coderabbitai help to get the list of available commands and usage tips.

@dane-ai-mastra dane-ai-mastra Bot added the tests: no tests added PR does not change test files label Jun 18, 2026
Group the Session's sub-objects into four phases (where the conversation
lives, how the agent behaves, what's happening now, what you store and
render) with anchor links so readers can orient before the detailed
sections. Add context to the Follow-ups section, fold the
Harness-performs / Session-reads split into one sentence, and refresh
the page description.
Modes page: replace 'When to use modes' with a 'Modes are required'
section that explains what a mode is (instructions, tools, model), states
that the modes array is required and a Harness needs at least one, and
notes how the default mode is chosen.

Session page: replace the hand-wavy 'coalesced' description of display
state with a concrete explanation — it's a reducer-maintained snapshot
that folds every harness event into one HarnessDisplayState object,
listing the fields it carries and the recommended subscribe-and-render
pattern.
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui June 18, 2026 14:40 Inactive
Drop the standalone heading and explain that modes are required as part
of the opening explanation of what modes are.
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui June 18, 2026 14:41 Inactive
Introduce the query methods before the code block, noting the Harness
owns the mode catalog and the Session tracks the active mode.
Fold the threads-vs-state guidance into the intro prose instead of a
standalone 'When to use' section.
Resource IDs: stop showing the runtime harness.setResourceId() mutation
(ambiguous in a multi-session host) and present resourceId as
constructor config read back through session.identity. Update the
Session page Identity section to match.

Drop the standalone 'When to use' headings from tool-approvals and
subagents, folding the guidance into each page's intro.
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui June 18, 2026 14:47 Inactive
Explain what a thread and state each are and why they matter before the
API examples: a thread is the persistent message history, state is the
structured shared data alongside it, and both survive mode switches,
model changes, and restarts. Add lead paragraphs to the Threads and
State sections and remove the duplicated intro definition.
Explain that a subagent's description drives when the parent delegates
and its instructions keep the child in scope, so both should be clear
and narrow. Note that narrow scoping plus allowedWorkspaceTools keeps
routing predictable and avoids over-delegation.
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui June 18, 2026 14:51 Inactive
Remove the 'instructions: ... // Ignored in forked mode' line from the
forked subagent example. Showing a field that does nothing in this
example is confusing; the Forked mode semantics list already documents
that the definition's instructions are ignored.
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui June 18, 2026 14:52 Inactive
Lead with the use case: forks reuse the parent agent and a clone of the
parent thread so the subagent gets full conversation context and an
identical prompt prefix (prompt-cache reuse), which is the point of
forking. Clarify that the definition's instructions/tools/model are
ignored in a fork (only description matters), and fix the incorrect
claim that the parent maxSteps applies — forked runs use a fixed step
budget, not the parent's.
Remove the sentence describing how the startup mode is chosen
(metadata.default / defaultModeId / first mode) — too in the weeds for
the intro.
Remove the 'line between a framework and a harness' sentence; fold the
lifecycle/context/outside-world detail into the harness definition.
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui June 18, 2026 15:01 Inactive
Replace the 'agent harness is the runtime' framing with the original
session-controller opening paragraph.
A Session has one active thread at a time but can list, switch between,
and clone many threads, so it is not scoped to a single conversation.
Reframe the intro and 'What the Session tracks' around a single user's
live state scoped by identity, and correct the multi-session note to
'many users' rather than 'many conversations'.
@vercel vercel Bot temporarily deployed to Preview – mastra-playground-ui June 18, 2026 15:04 Inactive
Replace the field-by-field HarnessDisplayState list with a prose
summary of what the snapshot captures; the reference note already links
the full field list.
@abhiaiyer91 abhiaiyer91 merged commit bf042ea into main Jun 18, 2026
43 checks passed
@abhiaiyer91 abhiaiyer91 deleted the astonishing-oval branch June 18, 2026 15:08
wardpeet pushed a commit that referenced this pull request Jun 19, 2026
## Summary

Improves the Harness documentation so it explains what a harness is and
what it's for before diving into APIs.

### Harness overview
- Lead with a clear definition of an agent harness: the runtime that
wraps a model and governs its behavior, distinct from the framework you
build an agent from.
- Rewrite the "What you can build" section to be outcome-driven — each
item maps a concrete result to the capability and doc page that delivers
it.
- Reframe "When to use the Harness" so it no longer implies the Agent
class is only for one-shot calls; the Harness is positioned as an
opinionated default for collaborative-session apps.
- Add missing reference links: model router, signals, the events
reference, and observational memory.

### Session page
- Link the first mention of `Session` to the Session reference page.
- Replace the Harness-vs-Session comparison table with a high-level
description of the Session's scope of responsibilities.

## Test plan
- Docs-only change. Verified every internal link resolves to an existing
page or in-page anchor, and confirmed the Harness Quickstart code
matches the current `Harness` API (constructor config, mode shape, and
the `init` / `selectOrCreateThread` / `sendMessage` / `subscribe`
methods) in `packages/core/src/harness`.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5 Explanation

This PR makes the Harness docs easier to understand by first explaining,
in plain terms, what the Harness is (a runtime that controls how a model
behaves) and what you can build with it. It also rewrites the Session
and Modes pages so readers know exactly what each thing tracks/controls,
and it adds missing links to related references.

## Overview Changes

**docs/src/content/en/docs/harness/overview.mdx**
- **Sharper definition up front:** Replaces earlier wording with a clear
explanation that the Harness is a **runtime** that wraps a model and
governs its behavior (separate from the agent/framework used to build an
agent).
- **Outcome-driven “What you can build”:** Rewrites the section to map
concrete results to capabilities, including:
  - Persistent threads/state management
  - Tool-approval gating
  - Modes on a single thread
  - Runtime model switching
  - Subagents
  - Live UI/event driving
  - Long-lived autonomous agents
- **Reframed “When to use the Harness”:** Positions the Harness as an
opinionated default for **collaborative-session** apps, clarifying that
`Agent` is better suited for full control or one-shot calls.
- **Reference link gaps filled:** Adds missing links for the **model
router**, **signals**, the **events reference** (including
`HarnessDisplayState`), and **observational memory**.

## Session Page Changes

**docs/src/content/en/docs/harness/session.mdx**
- **Removed “Harness vs. Session” comparison:** Replaces it with a
clearer, high-level description of the Session’s scope.
- **Better Session framing:** Adds “What the Session tracks,” describing
Session as per-conversation live state and breaking down Session
sub-objects in conversation-building order.
- **Follow-ups clarified:** Explains that follow-ups added during an
active run are queued on `session.followUps`, and introduces mid-run
redirection via `harness.steer({ content })` (signals-based).
- **Display state rewritten and concretized:** Updates
`session.displayState` to a **reducer-maintained snapshot** that folds
harness events into a single `HarnessDisplayState` object, including
guidance to **subscribe and render** when `display_state_changed` fires.
- **First `Session` mention linked:** The initial use of `Session` on
the page now links to the Session reference.

## Modes Page Changes

**docs/src/content/en/docs/harness/modes.mdx**
- **What a mode is (and that it’s required):** Adds a clear explanation
that modes must be provided and what they consist of (e.g.,
instructions, tools, model).
- **Startup/selection behavior clarified:** Documents what happens when
modes are empty and how the default mode is chosen (via metadata like
`default` / `defaultModeId`, or the first mode).
- **Querying modes clarified:** Expands guidance that the Harness owns
the mode catalog while the Session tracks the active mode, referencing
`harness.listModes()`, `harness.session.mode.get()`, and
`harness.session.mode.resolve()`.

## Testing / Validation Notes

- Internal links were verified to resolve correctly.
- Harness Quickstart code was confirmed to match the current Harness API
in `packages/core/src/harness` (constructor config, mode shape, and
`init`, `selectOrCreateThread`, `sendMessage`, `subscribe`).
- Changes are documentation-only.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Mastra Code (anthropic/claude-opus-4-8) <noreply@mastra.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

complexity: low Low-complexity PR Documentation Improvements or additions to documentation tests: no tests added PR does not change test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants