Skip to content

docs(evals): updated examples to be async#2846

Open
poshinchen wants to merge 1 commit into
strands-agents:mainfrom
poshinchen:docs/evals-all-async
Open

docs(evals): updated examples to be async#2846
poshinchen wants to merge 1 commit into
strands-agents:mainfrom
poshinchen:docs/evals-all-async

Conversation

@poshinchen

Copy link
Copy Markdown
Contributor

Description

Updated most of the examples and code snippet to use async.

Related Issues

N/A

Documentation PR

N/A

Type of Change

Documentation update
Other (please describe):

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@poshinchen poshinchen deployed to auto-approve June 16, 2026 21:59 — with GitHub Actions Active
@github-actions github-actions Bot added bug Something isn't working documentation Documentation changes, improvements, additions, content updates, site improvements, examples, guides python Pull requests that update python code strands-running labels Jun 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Documentation Preview Ready

Your documentation preview has been successfully deployed!

Changed pages:

Updated at: 2026-06-16T22:05:58.410Z

async def main():
report = await experiment.run_evaluations_async(my_agent_task, max_workers=1)

asyncio.run(main())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: report is now scoped inside main() and discarded, but the following snippets ("Viewing Recommendations" and "Accessing Full Diagnosis Data") still reference report.display(...) and report.recommendations at module level. A reader copy-pasting these blocks in sequence will hit a NameError.

Suggestion: Either return report from main() and bind it (report = asyncio.run(main())), or move the display/recommendation calls inside main() — the way the second full example further down (L254–261) already does. Worth keeping the two examples in this same file consistent.

async def main():
report = await experiment.run_evaluations_async(task_function)

asyncio.run(main())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: report is assigned but never used here (no run_display()/return), so the snippet runs the evaluation and silently throws the result away.

Suggestion: Either drop the assignment, or add report.run_display() inside main() for consistency with the first example on this page. Same pattern appears in evaluators/index.mdx (L297–300).

@github-actions

Copy link
Copy Markdown
Contributor

Assessment: Comment

Clean, consistent conversion of the evals examples to run_evaluations_async. The async wrapping is correct, and removing memory_exporter.clear() from task functions is the right call — map_to_session(..., session_id=...) already isolates spans per case, and clearing a shared exporter would be unsafe once max_workers > 1. A couple of snippets need a small fix so they stay copy-paste-runnable.

Review themes
  • Snippet continuity: In diagnosis.mdx the first example now scopes report inside main(), but later standalone blocks still reference it at module level — a copy-paste reader hits NameError. The second example on the same page handles this correctly; worth aligning them.
  • Dead assignments: A few converted snippets (correctness_evaluator.mdx 2nd example, evaluators/index.mdx) assign report but never display or return it.
  • Scope/consistency: Some examples (quickstart, eval_task, simulators) are intentionally left on the sync pattern. Reasonable, but a note in the description on what was left and why would help reviewers.
  • max_workers: Passing max_workers=1 only where a shared TracedHandler/exporter is involved is correct; defaulting elsewhere is fine.

Nice, low-risk improvement that gets the docs aligned with the async-first API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Documentation changes, improvements, additions, content updates, site improvements, examples, guides python Pull requests that update python code size/l

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant