Skip to content

docs: fix broken _astructured_completion example in thread-safety.mdx (removed by PraisonAI PR #3991) #2961

Description

@MervinPraison

Summary

PraisonAI PR #3991 (merged 2026-08-16, closes #3990) removed the dead private method BaseAutoGenerator._astructured_completion from src/praisonai/praisonai/auto.py. The method had zero call sites in the SDK — but docs/features/thread-safety.mdx still teaches users to call it directly in a copy-paste code example, and mentions it in two behaviour-change notes. The code example will now raise AttributeError on any current install.

This is a small, well-scoped fix — one file, three edits.

Upstream source of truth:


Edits required — all in docs/features/thread-safety.mdx

Edit 1 · Fix the broken async code example

Current (broken — method no longer exists):

# Async context manager
async with BaseAutoGenerator(config_list=[{
    "model": "gpt-4o-mini",
    "api_key": os.getenv("OPENAI_API_KEY"),
    "base_url": None,
}]) as gen:
    result = await gen._astructured_completion(MyModel, messages=[...])

Replace the last line with the live async path (verified against src/praisonai/praisonai/auto.py:718-732 on main):

    result = await gen._structured_completion_async(MyModel, messages=[...], is_async=True)

_structured_completion_async(..., is_async=True) is what _astructured_completion internally delegated to. Issue #3990 explicitly states its behaviour is "fully covered by _structured_completion_async(is_async=True)".

Edit 2 · Remove the stale reference in the PR #1736 warning

Current:

Behaviour change in PR #1736: __del__ was removed and async support was added. New methods include aclose, __aenter__/__aexit__, and _astructured_completion. Use context managers or explicit cleanup instead of relying on destructors.

Update to:

Behaviour change in PR #1736: __del__ was removed and async support was added. New methods include aclose, __aenter__/__aexit__, and _structured_completion_async (originally added as _astructured_completion, renamed and consolidated on the live path — the shorter alias was removed as dead code in PR #3991). Use context managers or explicit cleanup instead of relying on destructors.

Edit 3 · Remove the stale reference in the PR #2963 warning

Current:

Behaviour change in PR for #2963: BaseAutoGenerator now owns a single _core_client: OpenAIClient (the core-owned client) instead of separate _openai_client / _async_openai_client attributes. The methods _get_openai_client() and _get_async_openai_client() were consolidated into _get_core_client(). The public surface (close, aclose, __enter__/__exit__, __aenter__/__aexit__, _structured_completion, _astructured_completion) is unchanged.

Update to (drop the stale name from the surface list; keep the sentence's meaning intact):

Behaviour change in PR for #2963: BaseAutoGenerator now owns a single _core_client: OpenAIClient (the core-owned client) instead of separate _openai_client / _async_openai_client attributes. The methods _get_openai_client() and _get_async_openai_client() were consolidated into _get_core_client(). The public surface (close, aclose, __enter__/__exit__, __aenter__/__aexit__, _structured_completion, _structured_completion_async) is unchanged as of PR #2963. _astructured_completion was later removed as dead code in PR #3991 — call _structured_completion_async instead.


Why this matters

  • docs/features/thread-safety.mdx is a "power user" page, and the example lives under the deliberate heading "For power users building generators directly". Any user who copies it will hit AttributeError: 'BaseAutoGenerator' object has no attribute '_astructured_completion' on the very next release.
  • The two behaviour-change notes are documentation of intent — leaving a removed symbol in the "new methods" and "public surface" lists misleads maintainers about what the API actually is today.
  • Both fixes are additive text-only edits in a single existing page; no new page, no docs.json change, no diagram rework.

Placement checklist (per repo AGENTS.md)

  • Edits stay in docs/features/thread-safety.mdx — do not migrate the page or split it.
  • Do not touch docs/concepts/ (human-approved only).
  • Do not modify auto-generated docs/sdk/reference/** — those regenerate from source.
  • Re-verify the replacement signature against src/praisonai/praisonai/auto.py at head SHA 33d8aaf5cb7c605a09e0013c7f2020e947303257 before pushing.

Out of scope


Filed by the docs-triage scheduled routine on 2026-08-16, triggered by the pull_request.closed webhook for PraisonAI PR #3991. Verified against upstream diff at head SHA 33d8aaf5cb7c605a09e0013c7f2020e947303257.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclaudeTrigger Claude Code analysisdocumentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions