Repository navigation
Python: preserve roles in Claude prompt history - #1
Closed
jpalvarezl wants to merge 3 commits into
Closed
jpalvarezl wants to merge 3 commits into
jpalvarezl wants to merge 3 commits into
Conversation
jpalvarezl
had a problem deploying
to
github-app-auth
September 4, 2026 12:15 — with
GitHub Actions
Failure
jpalvarezl
had a problem deploying
to
github-app-auth
September 4, 2026 12:15 — with
GitHub Actions
Failure
jpalvarezl
had a problem deploying
to
github-app-auth
September 4, 2026 12:15 — with
GitHub Actions
Failure
jpalvarezl
had a problem deploying
to
github-app-auth
September 4, 2026 12:19 — with
GitHub Actions
Failure
jpalvarezl
had a problem deploying
to
github-app-auth
September 4, 2026 12:28 — with
GitHub Actions
Failure
jpalvarezl
had a problem deploying
to
github-app-auth
September 7, 2026 11:31 — with
GitHub Actions
Failure
jpalvarezl
had a problem deploying
to
github-app-auth
September 7, 2026 12:20 — with
GitHub Actions
Failure
jpalvarezl
had a problem deploying
to
github-app-auth
September 7, 2026 12:35 — with
GitHub Actions
Failure
jpalvarezl
marked this pull request as ready for review
September 7, 2026 12:38
jpalvarezl
had a problem deploying
to
github-app-auth
September 7, 2026 12:39 — with
GitHub Actions
Failure
jpalvarezl
had a problem deploying
to
github-app-auth
September 7, 2026 12:39 — with
GitHub Actions
Failure
jpalvarezl
pushed a commit
that referenced
this pull request
Sep 28, 2026
…osoft#8201) (microsoft#8284) * Python: add public TypedDict for AgentExecutor checkpoint state (microsoft#8201) Expose AgentExecutorCheckpointState / AgentSessionCheckpointState, validate restore field types, and cover partial/malformed/forward-compatible payloads. * fix(checkpoint): address microsoft#8284 review on session TypedDict ownership (#1) - Define AgentSessionDict on AgentSession (to_dict return) so the shape is not duplicated in AgentExecutor; keep AgentSessionCheckpointState as alias. - Include ServiceSessionId mapping in service_session_id. - Type on_checkpoint_restore as AgentExecutorCheckpointState only. - Sync root stub exports (__init__.pyi) with runtime __all__. * fix(checkpoint): validate AgentExecutor restore element types (microsoft#8284) Enforce Message/Content element types, string pending-request keys, and required agent_session.session_id so malformed checkpoints fail at restore. * fix(checkpoint): validate AgentSessionDict fields on restore - Validate agent_session.state / service_session_id types - Raise WorkflowCheckpointException when session restore fails - Drop unshipped AgentSessionCheckpointState alias; use AgentSessionDict * fix(checkpoint): keep session/executor checkpoint payloads as dict TypedDict schemas remain public for documentation and validation, but to_dict and on_checkpoint_save/restore stay dict[str, Any] so subclasses, samples, and pyright stay compatible. * fix(checkpoint): keep AgentSessionDict optional keys under postponed annotations Use a required base plus total=False subclass, stop exporting AgentSessionDict from the public package root, and tighten AgentExecutor restore validation with walrus checks. --------- Co-authored-by: minelhi <3417378192@qq.com> Co-authored-by: LI <2484593937@qq.com> Co-authored-by: Evan Mattson <35585003+moonbox3@users.noreply.github.com> Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
ClaudeAgentcurrently flattens incoming messages into a single prompt without preserving their roles. In multi-agent workflows, this makes user input and previous agents' responses indistinguishable. This change retains role information and explicitly frames the supplied transcript as conversation history for the receiving agent's assigned task.Description & Review Guide
_format_prompt()to prepend a conversation-history explanation and label each message with its role, while leaving a single user message unchanged. Add regression coverage for mixed-role history, messages from named and unnamed agents, and a single assistant message. Add a documentedSequentialBuildersample that passes a grammar inspector's output to a second Claude agent. Broaden thefunction_invocation_kwargsandclient_kwargsannotations fromdicttoMappingin therun()signatures.Related Issue
Fixes microsoft#7894
This overlaps with microsoft#7895, which also introduces role labels. This PR additionally provides explicit conversation-history framing, broader formatting coverage, a sequential-agent sample, and the
Mappingannotation updates.Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.