-
Notifications
You must be signed in to change notification settings - Fork 178
feat(examples): add rest examples from docs #2086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
dccb261
feat(examples): convert rest of examples from docs
aleskalfas 7244096
fixup!
aleskalfas ded13d1
feat(examples): separate e2e tests from e2e examples
aleskalfas cc5cd35
feat(examples): add gitignore for uv.locks
aleskalfas 789f120
fixup!
aleskalfas cabab33
fixup!
aleskalfas 5359d41
fixup!
aleskalfas bf67636
fix(examples): return uv.locks
aleskalfas cdec907
fix(examples): increase timeout to 45 min
aleskalfas 189054f
fix(examples): embedding
aleskalfas e664e13
fixup!
aleskalfas f80e28f
fix(e2e): missing client id
aleskalfas 3274541
fix(e2e): skip login
aleskalfas ac38e8d
feat(examples): pass llm model into testing agent via env
aleskalfas d328cd9
feat(examples): add overview examples
aleskalfas b289ed9
fixup!
aleskalfas cd37ea8
feat(examples): merged basic setting example
aleskalfas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| name: e2e-examples-test | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| workflow_dispatch: { } | ||
| pull_request: | ||
| types: [labeled, synchronize] | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'apps/agentstack-server/**' | ||
| - 'apps/agentstack-sdk-py/**' | ||
| - 'examples/**' | ||
| - 'helm/**' | ||
| jobs: | ||
| e2e-examples-test: | ||
| if: >- | ||
| github.event_name != 'pull_request' || | ||
| contains(github.event.pull_request.labels.*.name, 'e2e-examples') | ||
| timeout-minutes: 45 | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| AGENTSTACK__HOME: ${{ github.workspace }}/.agentstack | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Maximize build space | ||
| uses: ./.github/actions/maximize-build-space | ||
| with: | ||
| root-reserve-mb: 15360 | ||
| temp-reserve-mb: 2048 | ||
| swap-size-mb: 1024 | ||
| remove-dotnet: 'true' | ||
| - name: "Set up Lima" | ||
| uses: lima-vm/lima-actions/setup@v1 | ||
| id: lima-actions-setup | ||
| - name: "Cache ~/.cache/lima" | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/lima | ||
| key: lima-${{ steps.lima-actions-setup.outputs.version }} | ||
| - uses: actions/checkout@v4 | ||
| - uses: ./.github/actions/setup | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - run: mise run agentstack-server:test:e2e-examples | ||
| env: | ||
| LLM_API_BASE: "${{ secrets.OPENAI_API_BASE }}" | ||
| LLM_MODEL: "${{ vars.OPENAI_MODEL }}" | ||
| EMBEDDING_MODEL: "${{ vars.OPENAI_EMBEDDING_MODEL }}" | ||
| LLM_API_KEY: "${{ secrets.OPENAI_API_KEY }}" | ||
| - run: uv cache prune --ci |
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
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
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
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
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
57 changes: 57 additions & 0 deletions
57
...ack-server/tests/e2e/examples/agent-integration/agent-details/test_basic_configuration.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Copyright 2025 © BeeAI a Series of LF Projects, LLC | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import pytest | ||
|
|
||
| from agentstack_server.domain.constants import AGENT_DETAIL_EXTENSION_URI | ||
| from agentstack_server.utils.a2a import get_extension | ||
| from tests.e2e.examples.conftest import run_example | ||
|
|
||
| pytestmark = pytest.mark.e2e | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures("clean_up", "setup_platform_client") | ||
| async def test_basic_configuration_example(subtests, get_final_task_from_stream, a2a_client_factory): | ||
| example_path = "agent-integration/agent-details/basic-configuration" | ||
|
|
||
| async with run_example(example_path, a2a_client_factory) as running_example: | ||
| agent_card = running_example.agent_card | ||
|
|
||
| with subtests.test("agent card has correct name"): | ||
| assert agent_card.name == "Example Research Assistant" | ||
|
|
||
| with subtests.test("agent card has two skills"): | ||
| assert agent_card.skills is not None | ||
| assert len(agent_card.skills) == 2 | ||
|
|
||
| skill_ids = {skill.id for skill in agent_card.skills} | ||
| assert skill_ids == {"research", "summarization"} | ||
|
|
||
| with subtests.test("agent detail extension is configured"): | ||
| agent_detail = get_extension(agent_card, AGENT_DETAIL_EXTENSION_URI) | ||
| assert agent_detail is not None | ||
|
|
||
| params = agent_detail.model_dump()["params"] | ||
| assert params["interaction_mode"] == "multi-turn" | ||
| assert ( | ||
| params["user_greeting"] == "Hi there! I can help you research topics or summarize uploaded documents." | ||
| ) | ||
| assert params["framework"] == "BeeAI Framework" | ||
| assert params["source_code_url"] == "https://github.com/example/example-research-assistant" | ||
|
|
||
| with subtests.test("agent detail has author info"): | ||
| agent_detail = get_extension(agent_card, AGENT_DETAIL_EXTENSION_URI) | ||
| params = agent_detail.model_dump()["params"] | ||
|
|
||
| assert params["author"]["name"] == "Agent Stack Team" | ||
| assert params["author"]["email"] == "team@example.com" | ||
|
|
||
| with subtests.test("agent detail has tools"): | ||
| agent_detail = get_extension(agent_card, AGENT_DETAIL_EXTENSION_URI) | ||
| params = agent_detail.model_dump()["params"] | ||
|
|
||
| tools = params["tools"] | ||
| assert len(tools) == 2 | ||
|
|
||
| tool_names = {tool["name"] for tool in tools} | ||
| assert tool_names == {"Web Search", "Document Reader"} | ||
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
65 changes: 65 additions & 0 deletions
65
apps/agentstack-server/tests/e2e/examples/agent-integration/canvas/test_canvas_with_llm.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Copyright 2025 © BeeAI a Series of LF Projects, LLC | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import pytest | ||
| from a2a.client.helpers import create_text_message_object | ||
| from a2a.types import TaskState | ||
| from agentstack_sdk.a2a.extensions.ui.canvas import CanvasExtensionSpec | ||
|
|
||
| from tests.e2e.examples.conftest import run_example | ||
|
|
||
| pytestmark = pytest.mark.e2e | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures("clean_up", "setup_platform_client") | ||
| async def test_canvas_with_llm_example(subtests, get_final_task_from_stream, a2a_client_factory): | ||
| example_path = "agent-integration/canvas/canvas-with-llm" | ||
|
|
||
| async with run_example(example_path, a2a_client_factory) as running_example: | ||
| canvas_uri = CanvasExtensionSpec.URI | ||
|
|
||
| with subtests.test("agent generates code artifact"): | ||
| message = create_text_message_object(content="Write a hello world program") | ||
| message.context_id = running_example.context.id | ||
| task = await get_final_task_from_stream(running_example.client.send_message(message)) | ||
|
|
||
| assert task.status.state == TaskState.completed, f"Fail: {task.status.message.parts[0].root.text}" | ||
|
|
||
| # Verify artifact is returned (the agent uses a mocked LLM response) | ||
| assert len(task.artifacts) > 0 | ||
| artifact = task.artifacts[0] | ||
| assert artifact.name == "Response" | ||
|
|
||
| # Verify the artifact contains the expected mock response | ||
| artifact_text = "".join(part.root.text for part in artifact.parts if hasattr(part.root, "text")) | ||
| assert "Hello from LLM!" in artifact_text | ||
|
|
||
| with subtests.test("agent updates artifact via canvas edit"): | ||
| # Use the artifact from the previous test | ||
| artifact_id = artifact.artifact_id | ||
|
|
||
| # Get the artifact text to determine indices | ||
| artifact_text = "".join(part.root.text for part in artifact.parts if hasattr(part.root, "text")) | ||
|
|
||
| # Send edit request for a portion of the code | ||
| message = create_text_message_object(content="Change print to use f-string") | ||
| message.context_id = running_example.context.id | ||
| message.metadata = { | ||
| canvas_uri: { | ||
| "artifact_id": artifact_id, | ||
| "start_index": 0, | ||
| "end_index": min(50, len(artifact_text)), # Select first 50 chars | ||
| "description": "Change print to use f-string", | ||
| } | ||
| } | ||
| task = await get_final_task_from_stream(running_example.client.send_message(message)) | ||
|
|
||
| assert task.status.state == TaskState.completed, f"Fail: {task.status.message.parts[0].root.text}" | ||
|
|
||
| # Verify updated artifact is returned | ||
| assert len(task.artifacts) > 0 | ||
| updated_artifact = task.artifacts[0] | ||
|
|
||
| # Verify the response contains the edit prompt context | ||
| updated_text = "".join(part.root.text for part in updated_artifact.parts if hasattr(part.root, "text")) | ||
| assert "editing existing code" in updated_text.lower() or "selected" in updated_text.lower() |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.