acp-sdk 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/PKG-INFO +1 -1
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/examples/clients/simple.py +1 -1
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/pyproject.toml +1 -1
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/client/client.py +4 -1
- acp_sdk-0.2.4/src/acp_sdk/instrumentation.py +7 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/bundle.py +11 -4
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/telemetry.py +0 -4
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/tests/e2e/fixtures/server.py +2 -2
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/tests/e2e/test_suites/test_runs.py +3 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/.gitignore +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/.python-version +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/README.md +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/examples/clients/advanced.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/examples/clients/session.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/examples/clients/stream.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/examples/servers/awaiting.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/examples/servers/echo.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/examples/servers/standalone.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/pytest.ini +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/__init__.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/client/__init__.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/models/__init__.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/models/errors.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/models/models.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/models/schemas.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/py.typed +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/__init__.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/agent.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/app.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/context.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/errors.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/logging.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/server.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/session.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/types.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/server/utils.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/src/acp_sdk/version.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/tests/conftest.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/tests/e2e/__init__.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/tests/e2e/config.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/tests/e2e/fixtures/__init__.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/tests/e2e/fixtures/client.py +0 -0
- {acp_sdk-0.2.2 → acp_sdk-0.2.4}/tests/e2e/test_suites/__init__.py +0 -0
@@ -9,6 +9,7 @@ from httpx_sse import EventSource, aconnect_sse
|
|
9
9
|
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
|
10
10
|
from pydantic import TypeAdapter
|
11
11
|
|
12
|
+
from acp_sdk.instrumentation import get_tracer
|
12
13
|
from acp_sdk.models import (
|
13
14
|
ACPError,
|
14
15
|
Agent,
|
@@ -62,7 +63,9 @@ class Client:
|
|
62
63
|
|
63
64
|
@asynccontextmanager
|
64
65
|
async def session(self, session_id: SessionId | None = None) -> AsyncGenerator[Self]:
|
65
|
-
|
66
|
+
session_id = session_id or uuid.uuid4()
|
67
|
+
with get_tracer().start_as_current_span("session", attributes={"acp.session": str(session_id)}):
|
68
|
+
yield Client(client=self._client, session_id=session_id, instrument=False)
|
66
69
|
|
67
70
|
async def agents(self) -> AsyncIterator[Agent]:
|
68
71
|
response = await self._client.get("/agents")
|
@@ -5,15 +5,20 @@ from concurrent.futures import ThreadPoolExecutor
|
|
5
5
|
|
6
6
|
from pydantic import ValidationError
|
7
7
|
|
8
|
+
from acp_sdk.instrumentation import get_tracer
|
8
9
|
from acp_sdk.models import (
|
10
|
+
ACPError,
|
9
11
|
AnyModel,
|
10
12
|
AwaitRequest,
|
11
13
|
AwaitResume,
|
12
14
|
Error,
|
15
|
+
ErrorCode,
|
13
16
|
Event,
|
14
17
|
GenericEvent,
|
15
18
|
Message,
|
19
|
+
MessageCompletedEvent,
|
16
20
|
MessageCreatedEvent,
|
21
|
+
MessagePart,
|
17
22
|
MessagePartEvent,
|
18
23
|
Run,
|
19
24
|
RunAwaitingEvent,
|
@@ -24,11 +29,8 @@ from acp_sdk.models import (
|
|
24
29
|
RunInProgressEvent,
|
25
30
|
RunStatus,
|
26
31
|
)
|
27
|
-
from acp_sdk.models.errors import ErrorCode
|
28
|
-
from acp_sdk.models.models import MessageCompletedEvent, MessagePart
|
29
32
|
from acp_sdk.server.agent import Agent
|
30
33
|
from acp_sdk.server.logging import logger
|
31
|
-
from acp_sdk.server.telemetry import get_tracer
|
32
34
|
|
33
35
|
|
34
36
|
class RunBundle:
|
@@ -125,6 +127,8 @@ class RunBundle:
|
|
125
127
|
await_resume = await self.await_()
|
126
128
|
await self.emit(RunInProgressEvent(run=self.run))
|
127
129
|
run_logger.info("Run resumed")
|
130
|
+
elif isinstance(next, Error):
|
131
|
+
raise ACPError(error=next)
|
128
132
|
else:
|
129
133
|
try:
|
130
134
|
generic = AnyModel.model_validate(next)
|
@@ -142,7 +146,10 @@ class RunBundle:
|
|
142
146
|
await self.emit(RunCancelledEvent(run=self.run))
|
143
147
|
run_logger.info("Run cancelled")
|
144
148
|
except Exception as e:
|
145
|
-
|
149
|
+
if isinstance(e, ACPError):
|
150
|
+
self.run.error = e.error
|
151
|
+
else:
|
152
|
+
self.run.error = Error(code=ErrorCode.SERVER_ERROR, message=str(e))
|
146
153
|
self.run.status = RunStatus.FAILED
|
147
154
|
await self.emit(RunFailedEvent(run=self.run))
|
148
155
|
run_logger.exception("Run failed")
|
@@ -51,7 +51,3 @@ def configure_telemetry() -> None:
|
|
51
51
|
processor = BatchLogRecordProcessor(OTLPLogExporter())
|
52
52
|
logger_provider.add_log_record_processor(processor)
|
53
53
|
root_logger.addHandler(LoggingHandler(logger_provider=logger_provider))
|
54
|
-
|
55
|
-
|
56
|
-
def get_tracer() -> trace.Tracer:
|
57
|
-
return trace.get_tracer("acp-sdk", __version__)
|
@@ -4,7 +4,7 @@ from collections.abc import AsyncGenerator, AsyncIterator, Generator
|
|
4
4
|
from threading import Thread
|
5
5
|
|
6
6
|
import pytest
|
7
|
-
from acp_sdk.models import Artifact, AwaitRequest, AwaitResume, Message, MessagePart
|
7
|
+
from acp_sdk.models import Artifact, AwaitRequest, AwaitResume, Error, ErrorCode, Message, MessagePart
|
8
8
|
from acp_sdk.server import Context, Server
|
9
9
|
|
10
10
|
from e2e.config import Config
|
@@ -26,7 +26,7 @@ def server() -> Generator[None]:
|
|
26
26
|
|
27
27
|
@server.agent()
|
28
28
|
async def failer(inputs: list[Message], context: Context) -> AsyncIterator[Message]:
|
29
|
-
|
29
|
+
yield Error(code=ErrorCode.INVALID_INPUT, message="Wrong question buddy!")
|
30
30
|
|
31
31
|
@server.agent()
|
32
32
|
async def sessioner(inputs: list[Message], context: Context) -> AsyncIterator[Message]:
|
@@ -5,6 +5,7 @@ from acp_sdk.client import Client
|
|
5
5
|
from acp_sdk.models import (
|
6
6
|
ArtifactEvent,
|
7
7
|
AwaitResume,
|
8
|
+
ErrorCode,
|
8
9
|
Message,
|
9
10
|
MessageCreatedEvent,
|
10
11
|
MessagePart,
|
@@ -50,6 +51,8 @@ async def test_run_status(server: Server, client: Client) -> None:
|
|
50
51
|
async def test_failure(server: Server, client: Client) -> None:
|
51
52
|
run = await client.run_sync(agent="failer", inputs=inputs)
|
52
53
|
assert run.status == RunStatus.FAILED
|
54
|
+
assert run.error is not None
|
55
|
+
assert run.error.code == ErrorCode.INVALID_INPUT
|
53
56
|
|
54
57
|
|
55
58
|
@pytest.mark.asyncio
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|