AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

microsoft-foundry

Build, deploy, evaluate, optimize, fine-tune, and manage Microsoft Foundry agents, models, and resources end to end. USE FOR: foundry, azd ai agent, azd provision/deploy, hosted agent scaffold/develop/run/deploy/troubleshoot, prompt agent, managed harness agent, Copilot harness, voice agent, create/update/invoke/evaluate agent, add tool to agent, agent insights, batch/continuous eval, continuous monitoring, agent CI/CD, optimize/improve prompt, optimize agent instructions, Agent Optimizer, dataset curation from traces, deploy model, model fine-tuning (SFT/DPO/RFT), Foundry project, RBAC, role assignment, permissions, quota, capacity, region, deployment failure, AI Services, create Foundry resource, knowledge index, customize deployment, onboard, availability, training-data, grader, distillation, large file upload. DO NOT USE FOR: Azure Functions, App Service, general Azure deploy (use azure-deploy), general Azure prep (use azure-prepare).

Original source
microsoft
License
MIT
Pinned revision
3f5b461b2314e01c400564051e92469114c5b68f

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

This skill also requires local files or dependencies. Remote reading alone may not be enough.

Ask your assistant

Use Agentic Memory skills to read microsoft--microsoft-foundry at revision 3f5b461b2314e01c400564051e92469114c5b68f, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 151

foundry-agent/invoke/references/session-management.md

Hosted Session Management with azd

Use azd to manage session-backed compute and filesystem state for Hosted Agents.

Automatic Session Handling

For responses and invocations, start with azd ai agent invoke. Do not create a session first unless the workflow needs a known session before invocation.

Within an azd project, azd resolves session state for a normal remote invoke in this order:

  1. Use and persist an explicit --session-id.
  2. Reuse the session saved for the agent endpoint.
  3. If no session exists, let the server assign one, capture the returned session ID, and save it for later commands.

--new-session ignores the saved session and starts fresh session-backed state. --version <version> creates or reuses a session bound to that deployed version. Do not combine --version with --session-id.

File and monitor commands automatically use the session saved by invoke or sessions create. They also accept --session-id <id>.

Session and Conversation State

| State | Used by | azd behavior | |-------|---------|--------------| | Session | All directly invocable Hosted protocols | Persisted per agent; controls compute affinity and filesystem state | | Conversation | responses | Platform-managed; azd can persist the conversationId for reuse |

Use --new-conversation to reset responses history without replacing the session. Use --new-session to reset session-backed memory for invocations. --new-conversation has no effect for invocations. For completely fresh responses state, combine --new-session and --new-conversation.

Explicit Session Commands

Create a session when files must be uploaded before the first invoke, when a caller-selected ID is required, or when binding to a specific version:

azd ai agent sessions create
azd ai agent sessions create my-agent <version>
azd ai agent sessions create --session-id my-session

The create command auto-detects a single agent and resolves the deployed version from the azd environment. It prints JSON by default and persists agent_session_id as the current session.

Inspect and enumerate sessions:

azd ai agent sessions show <session-id>
azd ai agent sessions list
azd ai agent sessions list --limit 10 --output table
azd ai agent sessions list --pagination-token <token>

Use --agent-name <service-name> for show, stop, delete, or list when the project has multiple agent services. For header-based isolation, pass the same --user-identity on every session, invoke, file, and monitor command.

Stop Versus Delete

azd ai agent sessions stop <session-id>
azd ai agent sessions delete <session-id>

stop terminates running compute and preserves the persistent filesystem. It is idempotent, and a later invocation can resume the session.

delete synchronously removes compute and filesystem state. If the deleted ID is the saved current session, azd clears it from its session store.

Common Patterns

Continue a multi-turn interaction:

azd ai agent invoke "First question"
azd ai agent invoke "Follow-up question"

Reset responses history while keeping session files:

azd ai agent invoke --new-conversation "Start a new topic"

Reset session-backed memory:

azd ai agent invoke --new-session "Start fresh"

Preserve files without keeping compute running:

azd ai agent sessions stop <session-id>

WebSocket Sessions

invocations_ws is not called by azd ai agent invoke. Its client supplies agent_session_id on the WebSocket URL. Follow Invocations WebSocket for that connection lifecycle.