Repository navigation
Python: fix(python): validate settings and expose agent lifecycle methods - #8709
Merged
westey (westey-m) merged 3 commits intoSep 24, 2026
Merged
Conversation
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
September 23, 2026 18:17 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
September 23, 2026 18:18 — with
GitHub Actions
Inactive
Copilot started reviewing on behalf of
Eduard van Valkenburg (eavanvalkenburg)
September 23, 2026 18:18
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
September 23, 2026 18:18 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
September 23, 2026 18:18 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
September 23, 2026 18:18 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Nullable Any and non-string Literal settings are incorrectly rejected.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds stricter Python settings validation and explicit agent resource lifecycle management.
Changes:
- Validates environment and
.envscalar values. - Adds
open()andclose()to agents with cleanup handling. - Updates documentation and regression tests.
| File | Description |
|---|---|
python/packages/core/agent_framework/_settings.py |
Adds source-aware coercion errors. |
python/packages/core/agent_framework/_agents.py |
Adds explicit lifecycle methods and fixes examples. |
python/packages/core/tests/core/test_settings.py |
Tests settings validation and precedence. |
python/packages/core/tests/core/test_agents.py |
Tests lifecycle and partial-startup cleanup. |
python/packages/core/AGENTS.md |
Documents the new behavior. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Eduard van Valkenburg (eavanvalkenburg)
temporarily deployed
to
github-app-auth
September 24, 2026 07:19 — with
GitHub Actions
Inactive
westey (westey-m)
approved these changes
Sep 24, 2026
This branch was previously 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
Invalid optional numeric or boolean values supplied through environment variables and
.envfiles could silently become raw strings orFalse, hiding configuration mistakes. The agent documentation also used unsupported constructor arguments, and applications need explicit resource-lifecycle methods alongsideasync with.Description & Review Guide
.envscalar settings with field/source-specific errors while retaining precedence and valid provider settings; add asyncopen()/close()toRawAgentandAgent, delegate async context management to them, and clean up partial startup; correct thedefault_optionsexamples and add focused regressions.SecretString, and existing context-manager behavior remain supported. Explicit lifecycle control is now available.Related Issue
None; this PR intentionally has no linked issue.
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.