Python: preserve roles in Claude prompt history - #1
Closed
jpalvarezl wants to merge 3 commits into
Closed
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
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.