Prompt Chain

Orchestrate Multi-Turn Agent Interactions

Multi-step OpenAI Agents SDK workflow example demonstrating TypeScript features for building conversational agents that handle context beyond single-turn

Works with openai

54
Spark score
out of 100
Updated yesterday
Version code-scan-action-0.1
Models

Add to Favorites

Why it matters

Leverage advanced OpenAI Agents SDK features to build and manage complex, multi-turn agent interactions beyond simple single-turn conversations.

Outcomes

What it gets done

01

Implement multi-phase agent execution flows.

02

Manage agent communication and state across multiple turns.

03

Utilize advanced SDK features for sophisticated agent behavior.

04

Develop agents capable of complex task decomposition and execution.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-openai-agents-advanced | bash

Capabilities

What this chain does

Generate code

Writes source code or scripts from a description.

Review code

Analyzes code for bugs, style issues, and improvements.

Debug

Traces errors to their root cause and suggests fixes.

Overview

Openai Agents Advanced

What it does

This is a prompt chain example that demonstrates advanced OpenAI Agents SDK features in TypeScript. It exercises the SDK capabilities needed for multi-turn agent interactions, showing how to handle conversational context beyond simple single-turn exchanges. The example provides a working reference implementation for developers building stateful conversational agents.

How it connects

Use this when you're developing conversational AI agents that need to maintain context across multiple turns and want to understand how to leverage advanced OpenAI Agents SDK TypeScript features. It's particularly valuable when moving from prototype single-turn agents to production multi-turn implementations.

Source README

openai-agents-advanced (Sessions, Tracing, and Sandbox Agents)

This example exercises the OpenAI Agents SDK TypeScript features that matter once you move beyond a single-turn agent:

  • persistent MemorySession history
  • Promptfoo vars forwarded as SDK local run context
  • file-exported SDK tools
  • Promptfoo trajectory assertions over SDK traces
  • SandboxAgent execution with the SDK local sandbox client
  • sandbox skills loaded through SDK capability objects

Prerequisites

  • OPENAI_API_KEY

Installation

npx promptfoo@latest init --example openai-agents-advanced
cd openai-agents-advanced

Or, from a cloned repository:

cd examples/openai-agents-advanced
npm install

Run the session and tracing eval

npx promptfoo eval -c promptfooconfig.yaml --no-cache -j 1

The second test depends on the first test's remembered code word, so run this config with -j 1.

For stateful red-team strategies, use a session factory keyed by a per-test sessionId rather than one shared inline session. The OpenAI Agents provider docs show the transformVars plus session-factory pattern that keeps turns together without sharing history across unrelated tests; the multi-turn strategy docs explain when stateful: true is appropriate.

Run the sandbox and skill eval

npx promptfoo eval -c promptfooconfig.sandbox.yaml --no-cache

The sandbox eval mounts a synthetic task.md, asks the agent to use the ticket-summary skill, and asserts on traced shell activity plus the final answer.

See also the Tracing docs for trajectory assertions and the OpenAI Agents provider docs for the full JavaScript SDK configuration surface.

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.