agenticstar-platform 3.2.3__tar.gz → 3.4.0__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.
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/PKG-INFO +32 -5
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/README.md +31 -4
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/__init__.py +1 -1
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/config_access.py +2 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/metering/meter.py +60 -2
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/azure.py +15 -2
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/base.py +3 -1
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/gcs.py +17 -1
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/s3.py +27 -6
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/pyproject.toml +1 -1
- agenticstar_platform-3.4.0/tests/db/test_config_access_system_settings_order.py +45 -0
- agenticstar_platform-3.4.0/tests/metering/test_meter_call_detail.py +131 -0
- agenticstar_platform-3.4.0/tests/storage/test_download_version.py +225 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/workflow/test_workflow_testing.py +1 -1
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/LICENSE +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/_config_utils.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/audit/ROW_HASH_SPEC.md +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/audit/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/audit/action_audit.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/audit/guardrail_alerts.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/audit/row_hash_fixture.json +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/auth/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/auth/client.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/auth/config.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/auth/exceptions.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/auth/models.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/common/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/common/context_manager.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/common/secrets.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/common/validation.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/api_manager.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/completion_report.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/config.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/data_access.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/execution_access.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/factory.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/manager.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/pod_runtime.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/started_fence.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/telemetry_access.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/wire_types.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/events/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/events/emitter.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/events/handlers.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/events/models.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/events/types.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/README.md +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/__main__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/checks.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/docker-compose.yml +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/doctor.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/lab_config.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/offline_embedding.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/run_lab.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/lab/seed.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/memory/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/memory/semantic.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/metering/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/policy/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/policy/internal_operations.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/policy/model.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/rag/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/rag/base.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/rag/embedding.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/rag/qdrant_manager.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/runner.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/runtime.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/security/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/security/aws.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/security/azure.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/security/base.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/security/content_safety_validator.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/security/factory.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/security/gcp.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/paths.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/canonical.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/child.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/context.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/envelope.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/errors.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/files.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/runner.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/runtime_client.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/schema.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/workflow/testing.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/docs/agenticstar_platform.html +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/docs/examples/workflow_mock_send_agent.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/docs/examples/workflow_reply_agent.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/docs/index.html +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/docs/search.js +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/audit/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/audit/test_action_audit_30.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/audit/test_row_hash_fixture.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/auth/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/auth/test_auth_type_bearer_only.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/auth/test_get_user_path_encoding.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/auth/test_mcp_tokens_expiry.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/auth/test_mcp_tokens_rejected.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/db/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/db/test_api_manager_drain_and_headers.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/db/test_completion_report.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/db/test_data_access_identifier_validation.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/db/test_manager_execute_query_dispatch.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/db/test_telemetry_tools_used_contract.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/db/test_wire_param_types.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/events/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/events/test_handler_type_routing.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/events/test_notify_token.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/lab/test_lab_contract.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/lab/test_lab_docker.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/memory/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/memory/test_semantic_converter_base_url.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/metering/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/metering/test_meter_cache_split.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/policy/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/policy/test_a2a_connection_rule.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/policy/test_decision_layer.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/policy/test_evaluate_decision_table.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/policy/test_policy_model.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/policy/test_scoped_forbid.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/rag/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/rag/test_embedding_dimensions.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/rag/test_qdrant_error_hierarchy.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/rag/test_qdrant_get_statistics.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/runner/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/runner/test_marketplace_runner_contract.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/runner/test_marketplace_runner_db_fallback.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/runner/test_marketplace_runner_started_fence.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/security/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/security/test_azure_connect_retry.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/security/test_azure_prompt_shield_documents.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/security/test_factory_vertex_ai_safety.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/security/test_gcp_vertex_ai_safety.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/storage/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/storage/test_azure_credential.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/storage/test_s3_credential.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/test_lazy_import_contract.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/test_readme_quickstart.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/test_storage_provider_extra_contract.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/workflow/__init__.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/workflow/agent_fixtures.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/workflow/test_child_failure_summary.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/workflow/test_workflow_incomplete.py +0 -0
- {agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/tests/workflow/test_workflow_runner.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: agenticstar-platform
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: AGENTICSTAR Platform SDK - Enterprise AI Agent Infrastructure
|
|
5
5
|
Project-URL: Homepage, https://developers.fd.agenticstar.tm.softbank.jp/
|
|
6
6
|
Project-URL: Documentation, https://developers.fd.agenticstar.tm.softbank.jp/
|
|
@@ -491,6 +491,21 @@ config = S3Config.from_dict({
|
|
|
491
491
|
client = S3StorageClient(config)
|
|
492
492
|
```
|
|
493
493
|
|
|
494
|
+
A specific version (3.3.0): `download_file(object_name, download_path, version_id=...)` downloads that
|
|
495
|
+
version of the object instead of the latest one. The value is the Azure Blob `versionId`, the S3
|
|
496
|
+
`VersionId` or the GCS generation (a number as a string). A version that does not exist, and an empty
|
|
497
|
+
value, fail like a missing object (`BLOB_NOT_FOUND` on Azure, `OBJECT_NOT_FOUND` on S3 and GCS). To keep
|
|
498
|
+
the older version when an object is overwritten or deleted, turn on versioning (Azure: blob versioning of
|
|
499
|
+
the storage account; S3 and GCS: versioning of the bucket); versions kept earlier stay readable after it is
|
|
500
|
+
turned off. Without `version_id` the latest version is downloaded, as before.
|
|
501
|
+
|
|
502
|
+
```python
|
|
503
|
+
# S3: pass the VersionId that S3 returned for the object
|
|
504
|
+
result = await client.download_file(
|
|
505
|
+
"users/u1/report.docx", "/tmp/report.docx", version_id="3HL4kqtJlcpXroDTDmJ.rmSpXd3dIbrHY"
|
|
506
|
+
)
|
|
507
|
+
```
|
|
508
|
+
|
|
494
509
|
### Telemetry / LLM Usage Tracking (Marketplace)
|
|
495
510
|
|
|
496
511
|
`TelemetryAccess` (under `db` module) writes records to the `ai_telemetry` table. **Unknown fields are stored in the `metadata` jsonb column automatically** — no schema migration is required to add new tracking dimensions.
|
|
@@ -574,6 +589,7 @@ Dedicated LLM **usage & cost** infrastructure: computes cost from an LLM respons
|
|
|
574
589
|
- **DB**: any handle exposing `execute_query(query, params) -> {success, data, error}` (the SDK's `DataAccess` / `PostgreSQLManager`).
|
|
575
590
|
- **Usage status** (SDK ≥ 0.5.21): each row records `usage_status` (`present`/`missing`); when usage is absent, pass `missing_reason=` (e.g. `provider_omitted` / `stream_interrupted`). It is stored **on the row** (not just logs) so offline exports can tell `cost_usd IS NULL` (unpriced) vs `usage_status='missing'` vs true-zero apart. Present rows always store `NULL` (no contradiction).
|
|
576
591
|
- **Prompt-cache breakdown** (SDK ≥ 3.0.0): cache reads and cache writes are recorded separately in `cache_read_tokens` / `cache_creation_tokens` (both nullable; `cached_tokens` is kept as before). See the 3.0.0 changelog entry before upgrading writers on an existing ledger.
|
|
592
|
+
- **Per-call detail** (SDK ≥ 3.4.0): `record(..., reasoning_params=..., provider_model=...)` also stores the reasoning settings you sent to the model (a dict such as `{"reasoning_effort": "high"}`; `{}` means none were sent) in `reasoning_params` (jsonb) and the model name the provider reported in its response in `provider_model` (text). Both are optional; when you pass neither, `record` writes exactly the same row and SQL as before, so the ledger does not need the two columns. When you pass either, the ledger must have both columns (`ensure_schema()` adds them).
|
|
577
593
|
|
|
578
594
|
```python
|
|
579
595
|
from agenticstar_platform.metering import UsageMeter
|
|
@@ -598,7 +614,7 @@ await meter.rollup_recent()
|
|
|
598
614
|
rows = await meter.daily_cost(by="model", since_days=30) # by = "model" | "user" | "agent" | "day"
|
|
599
615
|
```
|
|
600
616
|
|
|
601
|
-
**Schema** (`ensure_schema`): `llm_usage_ledger` — one row per call (execution / message / conversation / user, model, in/out/total/cached tokens, cache read / creation tokens, `usage_status` + `missing_reason`, `cost_usd`, currency) — plus `llm_usage_daily` (rollup) and `rollup_llm_usage_daily(day)`. The default DDL is portable (any PostgreSQL); at scale, partition `llm_usage_ledger` monthly (e.g. pg_partman).
|
|
617
|
+
**Schema** (`ensure_schema`): `llm_usage_ledger` — one row per call (execution / message / conversation / user, model, in/out/total/cached tokens, cache read / creation tokens, `usage_status` + `missing_reason`, `reasoning_params` + `provider_model`, `cost_usd`, currency) — plus `llm_usage_daily` (rollup) and `rollup_llm_usage_daily(day)`. The default DDL is portable (any PostgreSQL); at scale, partition `llm_usage_ledger` monthly (e.g. pg_partman).
|
|
602
618
|
|
|
603
619
|
### Audit Module — `ActionAudit` / `GatewayActionAudit` (SDK ≥ 0.5.31)
|
|
604
620
|
|
|
@@ -801,7 +817,7 @@ automatically and go to a human (effects that already happened are never undone)
|
|
|
801
817
|
source distribution: `docs/examples/workflow_reply_agent.py` (drafting a reply) /
|
|
802
818
|
`workflow_mock_send_agent.py` (a mock send).
|
|
803
819
|
|
|
804
|
-
**Testing an agent without
|
|
820
|
+
**Testing an agent without AGENTIC STAR** (SDK ≥ 3.2.1). `agenticstar_platform.workflow.testing.FakeRuntime` answers the
|
|
805
821
|
platform's runtime API in memory. Give it your contract, the step's parameters, the input files, the connection tokens,
|
|
806
822
|
the effect mode and the deadline, run one step with `arun(...)`, then read what the runner saved. With this layout:
|
|
807
823
|
|
|
@@ -1128,6 +1144,17 @@ See the [developer portal](https://developers.fd.agenticstar.tm.softbank.jp/) fo
|
|
|
1128
1144
|
|
|
1129
1145
|
## Changelog
|
|
1130
1146
|
|
|
1147
|
+
### 3.4.0 (2026-11-24) — metering: the reasoning settings sent and the provider's model on each recorded call (`UsageMeter.record(..., reasoning_params=..., provider_model=...)`) / db: global system settings in priority order
|
|
1148
|
+
|
|
1149
|
+
- **`UsageMeter.record` takes two optional arguments.** `reasoning_params` is a dict of the reasoning settings you sent to the model (for example `{"reasoning_effort": "high"}`, `{"reasoning": {"effort": "high", "summary": "auto"}}` or `{"thinking": {"type": "enabled", "budget_tokens": 4096}}`; pass `{}` when none were sent). `provider_model` is the model name the provider reported in its response. They are stored in two new nullable columns of `llm_usage_ledger`: `reasoning_params` (jsonb) and `provider_model` (text). A value that cannot be stored as given is stored as `NULL` and the rest of the row is still written: a `reasoning_params` that is not a dict or cannot be stored as JSON (for example one holding `NaN`, an object, a NUL character or text that is not valid UTF-8), and a `provider_model` that is not a non-empty string or holds a NUL character or text that is not valid UTF-8.
|
|
1150
|
+
- **Callers that pass neither are unchanged**: `record` sends the same `INSERT` as before, so a ledger without the two columns keeps working. When you pass either argument, add the columns first: `ensure_schema()` now runs `ALTER TABLE llm_usage_ledger ADD COLUMN IF NOT EXISTS reasoning_params jsonb` and `... provider_model text` (idempotent; on a partitioned ledger the column is added to every partition), or run these two statements yourself. `LEDGER_DDL` creates new ledgers with both columns. With the default `fail_safe=True`, a write that fails because the columns are missing is skipped like any other ledger write: it is logged when your database handle raises, but a handle that reports failures in its return value (`{"success": False}`) gives no warning, so make sure the columns exist before you pass the arguments.
|
|
1151
|
+
- **`ConfigAccess.get_system_settings` returns the active global rows (the ones not tied to an organization) in ascending `priority`** (the order in which the admin console joins them). Before, the rows came back in no defined order, so a caller that joins them in the returned order could join them differently from the platform.
|
|
1152
|
+
|
|
1153
|
+
### 3.3.0 (2026-11-09) — storage: download a specific version (`download_file(..., version_id=...)`)
|
|
1154
|
+
|
|
1155
|
+
- **`download_file` takes an optional `version_id`** on `AzureBlobStorageClient`, `S3StorageClient` and `GCSStorageClient` (and on `StorageClientProtocol` / `StorageClientBase`). With it, the client checks and downloads that version: the Azure Blob `versionId`, the S3 `VersionId`, or the GCS generation given as a string of digits. A version that does not exist and an empty value fail like a missing object (`BLOB_NOT_FOUND` on Azure, `OBJECT_NOT_FOUND` on S3 and GCS); on GCS a value that is not a number fails the same way. Without `version_id` the client calls the storage exactly as before and downloads the latest version.
|
|
1156
|
+
- A storage client of your own that implements `StorageClientBase` should accept the new keyword argument; a caller that does not pass it is unaffected.
|
|
1157
|
+
|
|
1131
1158
|
### 3.2.3 (2026-11-04) — storage: S3 without access keys (IRSA) / events: a failed run ends the chat message
|
|
1132
1159
|
|
|
1133
1160
|
3.2.2 was not published to PyPI; 3.2.3 includes its change (the notify token below).
|
|
@@ -1147,7 +1174,7 @@ See the [developer portal](https://developers.fd.agenticstar.tm.softbank.jp/) fo
|
|
|
1147
1174
|
- **New `WorkflowContext.incomplete(reason, comment=None)`.** An agent that cannot complete its step, where running it again would give the same result (missing instructions, a wrong setting), ends the step as `incomplete` with `reason` as the reason code. The platform does not retry it automatically and asks a person to check it. `reason` follows the rules of `report_completion()` (lowercase snake_case of at most 32 characters; any other value becomes `incomplete` with a warning); `comment` is cut at 2,048 UTF-16 code units. The declaration comes after an audit persistence failure, cancellation, the deadline, the execution being closed elsewhere, a pod stop signal and a denied tool call, and before an exception (an exception after the declaration still ends as `incomplete`), an invalid output, a skip and a missing required output. A second declaration is not recorded. See "Ending a step as not completed" in the Workflow Runner section.
|
|
1148
1175
|
- **The completion carries an end-of-run report** (`completion_report`: `completed: false`, `reason_code`, `comment`) for `incomplete` (the agent's comment) and for an agent exception, `failed/agent_error` (the redacted cause chain the child already writes to stderr since 3.1.3: class names, the SDK's error code, the HTTP status and the host name; at most 2,048 UTF-16 code units, also with `ASTER_WORKFLOW_DEBUG_TRACEBACK=1`). Other outcomes carry no report, so their completion is the same as in 3.2. A platform that does not read the report yet keeps the completion and drops the report. A `comment` that is not a string (an exception, for example) is left out with a warning, so its message never reaches the report.
|
|
1149
1176
|
- **The cause chain shows an `error_code` only in the SDK's own form** (upper-case snake_case of at most 64 characters, such as `REQUEST_ERROR`), in stderr and in the report. An SDK exception that agent code created with another value no longer shows that value.
|
|
1150
|
-
- **New `agenticstar_platform.workflow.testing`**: `FakeRuntime`, an in-memory copy of the platform's runtime API for testing an agent without
|
|
1177
|
+
- **New `agenticstar_platform.workflow.testing`**: `FakeRuntime`, an in-memory copy of the platform's runtime API for testing an agent without AGENTIC STAR. It takes the contract, parameters, input files, connection tokens, effect mode, deadline and instructions as arguments, and `saved_artifacts()` / `saved_audit_events()` / `saved_completion()` read what the runner saved. It does not check the parameters or the contract (the platform checks them before a run). Like the platform, it accepts the audit records of what the agent already did (`tool.effect` / `tool.denied`) after cancellation, the end of the run or the deadline, and reports the end of the run in the context's `cancel_requested_at`. The supported surface (constructor arguments, `runner_env()`, `transport`, the `saved_*()` readers and the listed simulation attributes) is described in the module's docstring; everything else is internal. The SDK's own tests now use it. `import agenticstar_platform.workflow` does not import it.
|
|
1151
1178
|
- The sample `docs/examples/workflow_reply_agent.py` ends as `incomplete/missing_instructions` when the instructions are empty, and running the file runs one step against `FakeRuntime`.
|
|
1152
1179
|
- `build_envelope(...)` accepts an optional `completion_report`. Other public functions of the runner and the context are unchanged.
|
|
1153
1180
|
- To use it, rebuild the agent image with this SDK.
|
|
@@ -1588,4 +1615,4 @@ Marketplace SDK reliability fixes (surfaced while building agents from the guide
|
|
|
1588
1615
|
|
|
1589
1616
|
## Version
|
|
1590
1617
|
|
|
1591
|
-
3.
|
|
1618
|
+
3.4.0
|
|
@@ -410,6 +410,21 @@ config = S3Config.from_dict({
|
|
|
410
410
|
client = S3StorageClient(config)
|
|
411
411
|
```
|
|
412
412
|
|
|
413
|
+
A specific version (3.3.0): `download_file(object_name, download_path, version_id=...)` downloads that
|
|
414
|
+
version of the object instead of the latest one. The value is the Azure Blob `versionId`, the S3
|
|
415
|
+
`VersionId` or the GCS generation (a number as a string). A version that does not exist, and an empty
|
|
416
|
+
value, fail like a missing object (`BLOB_NOT_FOUND` on Azure, `OBJECT_NOT_FOUND` on S3 and GCS). To keep
|
|
417
|
+
the older version when an object is overwritten or deleted, turn on versioning (Azure: blob versioning of
|
|
418
|
+
the storage account; S3 and GCS: versioning of the bucket); versions kept earlier stay readable after it is
|
|
419
|
+
turned off. Without `version_id` the latest version is downloaded, as before.
|
|
420
|
+
|
|
421
|
+
```python
|
|
422
|
+
# S3: pass the VersionId that S3 returned for the object
|
|
423
|
+
result = await client.download_file(
|
|
424
|
+
"users/u1/report.docx", "/tmp/report.docx", version_id="3HL4kqtJlcpXroDTDmJ.rmSpXd3dIbrHY"
|
|
425
|
+
)
|
|
426
|
+
```
|
|
427
|
+
|
|
413
428
|
### Telemetry / LLM Usage Tracking (Marketplace)
|
|
414
429
|
|
|
415
430
|
`TelemetryAccess` (under `db` module) writes records to the `ai_telemetry` table. **Unknown fields are stored in the `metadata` jsonb column automatically** — no schema migration is required to add new tracking dimensions.
|
|
@@ -493,6 +508,7 @@ Dedicated LLM **usage & cost** infrastructure: computes cost from an LLM respons
|
|
|
493
508
|
- **DB**: any handle exposing `execute_query(query, params) -> {success, data, error}` (the SDK's `DataAccess` / `PostgreSQLManager`).
|
|
494
509
|
- **Usage status** (SDK ≥ 0.5.21): each row records `usage_status` (`present`/`missing`); when usage is absent, pass `missing_reason=` (e.g. `provider_omitted` / `stream_interrupted`). It is stored **on the row** (not just logs) so offline exports can tell `cost_usd IS NULL` (unpriced) vs `usage_status='missing'` vs true-zero apart. Present rows always store `NULL` (no contradiction).
|
|
495
510
|
- **Prompt-cache breakdown** (SDK ≥ 3.0.0): cache reads and cache writes are recorded separately in `cache_read_tokens` / `cache_creation_tokens` (both nullable; `cached_tokens` is kept as before). See the 3.0.0 changelog entry before upgrading writers on an existing ledger.
|
|
511
|
+
- **Per-call detail** (SDK ≥ 3.4.0): `record(..., reasoning_params=..., provider_model=...)` also stores the reasoning settings you sent to the model (a dict such as `{"reasoning_effort": "high"}`; `{}` means none were sent) in `reasoning_params` (jsonb) and the model name the provider reported in its response in `provider_model` (text). Both are optional; when you pass neither, `record` writes exactly the same row and SQL as before, so the ledger does not need the two columns. When you pass either, the ledger must have both columns (`ensure_schema()` adds them).
|
|
496
512
|
|
|
497
513
|
```python
|
|
498
514
|
from agenticstar_platform.metering import UsageMeter
|
|
@@ -517,7 +533,7 @@ await meter.rollup_recent()
|
|
|
517
533
|
rows = await meter.daily_cost(by="model", since_days=30) # by = "model" | "user" | "agent" | "day"
|
|
518
534
|
```
|
|
519
535
|
|
|
520
|
-
**Schema** (`ensure_schema`): `llm_usage_ledger` — one row per call (execution / message / conversation / user, model, in/out/total/cached tokens, cache read / creation tokens, `usage_status` + `missing_reason`, `cost_usd`, currency) — plus `llm_usage_daily` (rollup) and `rollup_llm_usage_daily(day)`. The default DDL is portable (any PostgreSQL); at scale, partition `llm_usage_ledger` monthly (e.g. pg_partman).
|
|
536
|
+
**Schema** (`ensure_schema`): `llm_usage_ledger` — one row per call (execution / message / conversation / user, model, in/out/total/cached tokens, cache read / creation tokens, `usage_status` + `missing_reason`, `reasoning_params` + `provider_model`, `cost_usd`, currency) — plus `llm_usage_daily` (rollup) and `rollup_llm_usage_daily(day)`. The default DDL is portable (any PostgreSQL); at scale, partition `llm_usage_ledger` monthly (e.g. pg_partman).
|
|
521
537
|
|
|
522
538
|
### Audit Module — `ActionAudit` / `GatewayActionAudit` (SDK ≥ 0.5.31)
|
|
523
539
|
|
|
@@ -720,7 +736,7 @@ automatically and go to a human (effects that already happened are never undone)
|
|
|
720
736
|
source distribution: `docs/examples/workflow_reply_agent.py` (drafting a reply) /
|
|
721
737
|
`workflow_mock_send_agent.py` (a mock send).
|
|
722
738
|
|
|
723
|
-
**Testing an agent without
|
|
739
|
+
**Testing an agent without AGENTIC STAR** (SDK ≥ 3.2.1). `agenticstar_platform.workflow.testing.FakeRuntime` answers the
|
|
724
740
|
platform's runtime API in memory. Give it your contract, the step's parameters, the input files, the connection tokens,
|
|
725
741
|
the effect mode and the deadline, run one step with `arun(...)`, then read what the runner saved. With this layout:
|
|
726
742
|
|
|
@@ -1047,6 +1063,17 @@ See the [developer portal](https://developers.fd.agenticstar.tm.softbank.jp/) fo
|
|
|
1047
1063
|
|
|
1048
1064
|
## Changelog
|
|
1049
1065
|
|
|
1066
|
+
### 3.4.0 (2026-11-24) — metering: the reasoning settings sent and the provider's model on each recorded call (`UsageMeter.record(..., reasoning_params=..., provider_model=...)`) / db: global system settings in priority order
|
|
1067
|
+
|
|
1068
|
+
- **`UsageMeter.record` takes two optional arguments.** `reasoning_params` is a dict of the reasoning settings you sent to the model (for example `{"reasoning_effort": "high"}`, `{"reasoning": {"effort": "high", "summary": "auto"}}` or `{"thinking": {"type": "enabled", "budget_tokens": 4096}}`; pass `{}` when none were sent). `provider_model` is the model name the provider reported in its response. They are stored in two new nullable columns of `llm_usage_ledger`: `reasoning_params` (jsonb) and `provider_model` (text). A value that cannot be stored as given is stored as `NULL` and the rest of the row is still written: a `reasoning_params` that is not a dict or cannot be stored as JSON (for example one holding `NaN`, an object, a NUL character or text that is not valid UTF-8), and a `provider_model` that is not a non-empty string or holds a NUL character or text that is not valid UTF-8.
|
|
1069
|
+
- **Callers that pass neither are unchanged**: `record` sends the same `INSERT` as before, so a ledger without the two columns keeps working. When you pass either argument, add the columns first: `ensure_schema()` now runs `ALTER TABLE llm_usage_ledger ADD COLUMN IF NOT EXISTS reasoning_params jsonb` and `... provider_model text` (idempotent; on a partitioned ledger the column is added to every partition), or run these two statements yourself. `LEDGER_DDL` creates new ledgers with both columns. With the default `fail_safe=True`, a write that fails because the columns are missing is skipped like any other ledger write: it is logged when your database handle raises, but a handle that reports failures in its return value (`{"success": False}`) gives no warning, so make sure the columns exist before you pass the arguments.
|
|
1070
|
+
- **`ConfigAccess.get_system_settings` returns the active global rows (the ones not tied to an organization) in ascending `priority`** (the order in which the admin console joins them). Before, the rows came back in no defined order, so a caller that joins them in the returned order could join them differently from the platform.
|
|
1071
|
+
|
|
1072
|
+
### 3.3.0 (2026-11-09) — storage: download a specific version (`download_file(..., version_id=...)`)
|
|
1073
|
+
|
|
1074
|
+
- **`download_file` takes an optional `version_id`** on `AzureBlobStorageClient`, `S3StorageClient` and `GCSStorageClient` (and on `StorageClientProtocol` / `StorageClientBase`). With it, the client checks and downloads that version: the Azure Blob `versionId`, the S3 `VersionId`, or the GCS generation given as a string of digits. A version that does not exist and an empty value fail like a missing object (`BLOB_NOT_FOUND` on Azure, `OBJECT_NOT_FOUND` on S3 and GCS); on GCS a value that is not a number fails the same way. Without `version_id` the client calls the storage exactly as before and downloads the latest version.
|
|
1075
|
+
- A storage client of your own that implements `StorageClientBase` should accept the new keyword argument; a caller that does not pass it is unaffected.
|
|
1076
|
+
|
|
1050
1077
|
### 3.2.3 (2026-11-04) — storage: S3 without access keys (IRSA) / events: a failed run ends the chat message
|
|
1051
1078
|
|
|
1052
1079
|
3.2.2 was not published to PyPI; 3.2.3 includes its change (the notify token below).
|
|
@@ -1066,7 +1093,7 @@ See the [developer portal](https://developers.fd.agenticstar.tm.softbank.jp/) fo
|
|
|
1066
1093
|
- **New `WorkflowContext.incomplete(reason, comment=None)`.** An agent that cannot complete its step, where running it again would give the same result (missing instructions, a wrong setting), ends the step as `incomplete` with `reason` as the reason code. The platform does not retry it automatically and asks a person to check it. `reason` follows the rules of `report_completion()` (lowercase snake_case of at most 32 characters; any other value becomes `incomplete` with a warning); `comment` is cut at 2,048 UTF-16 code units. The declaration comes after an audit persistence failure, cancellation, the deadline, the execution being closed elsewhere, a pod stop signal and a denied tool call, and before an exception (an exception after the declaration still ends as `incomplete`), an invalid output, a skip and a missing required output. A second declaration is not recorded. See "Ending a step as not completed" in the Workflow Runner section.
|
|
1067
1094
|
- **The completion carries an end-of-run report** (`completion_report`: `completed: false`, `reason_code`, `comment`) for `incomplete` (the agent's comment) and for an agent exception, `failed/agent_error` (the redacted cause chain the child already writes to stderr since 3.1.3: class names, the SDK's error code, the HTTP status and the host name; at most 2,048 UTF-16 code units, also with `ASTER_WORKFLOW_DEBUG_TRACEBACK=1`). Other outcomes carry no report, so their completion is the same as in 3.2. A platform that does not read the report yet keeps the completion and drops the report. A `comment` that is not a string (an exception, for example) is left out with a warning, so its message never reaches the report.
|
|
1068
1095
|
- **The cause chain shows an `error_code` only in the SDK's own form** (upper-case snake_case of at most 64 characters, such as `REQUEST_ERROR`), in stderr and in the report. An SDK exception that agent code created with another value no longer shows that value.
|
|
1069
|
-
- **New `agenticstar_platform.workflow.testing`**: `FakeRuntime`, an in-memory copy of the platform's runtime API for testing an agent without
|
|
1096
|
+
- **New `agenticstar_platform.workflow.testing`**: `FakeRuntime`, an in-memory copy of the platform's runtime API for testing an agent without AGENTIC STAR. It takes the contract, parameters, input files, connection tokens, effect mode, deadline and instructions as arguments, and `saved_artifacts()` / `saved_audit_events()` / `saved_completion()` read what the runner saved. It does not check the parameters or the contract (the platform checks them before a run). Like the platform, it accepts the audit records of what the agent already did (`tool.effect` / `tool.denied`) after cancellation, the end of the run or the deadline, and reports the end of the run in the context's `cancel_requested_at`. The supported surface (constructor arguments, `runner_env()`, `transport`, the `saved_*()` readers and the listed simulation attributes) is described in the module's docstring; everything else is internal. The SDK's own tests now use it. `import agenticstar_platform.workflow` does not import it.
|
|
1070
1097
|
- The sample `docs/examples/workflow_reply_agent.py` ends as `incomplete/missing_instructions` when the instructions are empty, and running the file runs one step against `FakeRuntime`.
|
|
1071
1098
|
- `build_envelope(...)` accepts an optional `completion_report`. Other public functions of the runner and the context are unchanged.
|
|
1072
1099
|
- To use it, rebuild the agent image with this SDK.
|
|
@@ -1507,4 +1534,4 @@ Marketplace SDK reliability fixes (surfaced while building agents from the guide
|
|
|
1507
1534
|
|
|
1508
1535
|
## Version
|
|
1509
1536
|
|
|
1510
|
-
3.
|
|
1537
|
+
3.4.0
|
|
@@ -9,7 +9,7 @@ import importlib
|
|
|
9
9
|
import importlib.util
|
|
10
10
|
from typing import TYPE_CHECKING
|
|
11
11
|
|
|
12
|
-
__version__ = "3.
|
|
12
|
+
__version__ = "3.4.0"
|
|
13
13
|
|
|
14
14
|
# Common utilities are internal - not exported as public API
|
|
15
15
|
# Use agenticstar_platform.common for internal SDK development only
|
{agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/db/config_access.py
RENAMED
|
@@ -448,10 +448,12 @@ class ConfigAccess:
|
|
|
448
448
|
"""
|
|
449
449
|
self.logger.info("[IN] get_system_settings")
|
|
450
450
|
try:
|
|
451
|
+
# 呼び手は返った順につなぐので、管理コンソールの連結順序 (priority) の昇順で返す (全体の行を読むときの executor・cli-api と同じ並び)
|
|
451
452
|
query = """
|
|
452
453
|
SELECT user_prompt, guardrail_text, is_active, priority
|
|
453
454
|
FROM system_settings
|
|
454
455
|
WHERE organization_id IS NULL AND is_active = true
|
|
456
|
+
ORDER BY priority ASC
|
|
455
457
|
"""
|
|
456
458
|
result = await self._db.execute_query(query)
|
|
457
459
|
|
{agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/metering/meter.py
RENAMED
|
@@ -29,8 +29,10 @@ DB は duck-typed: ``execute_query(query: str, params) -> {"success", "data", "e
|
|
|
29
29
|
"""
|
|
30
30
|
from __future__ import annotations
|
|
31
31
|
|
|
32
|
+
import json
|
|
32
33
|
import logging
|
|
33
34
|
import math
|
|
35
|
+
import re
|
|
34
36
|
from decimal import Decimal, InvalidOperation
|
|
35
37
|
from typing import Any, Callable, Optional
|
|
36
38
|
|
|
@@ -240,7 +242,9 @@ CREATE TABLE IF NOT EXISTS llm_usage_ledger (
|
|
|
240
242
|
cache_read_tokens integer,
|
|
241
243
|
cache_creation_tokens integer,
|
|
242
244
|
cost_usd numeric(14,8),
|
|
243
|
-
currency text NOT NULL DEFAULT 'USD'
|
|
245
|
+
currency text NOT NULL DEFAULT 'USD',
|
|
246
|
+
reasoning_params jsonb,
|
|
247
|
+
provider_model text
|
|
244
248
|
)
|
|
245
249
|
"""
|
|
246
250
|
|
|
@@ -300,6 +304,17 @@ INSERT INTO llm_usage_ledger
|
|
|
300
304
|
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21)
|
|
301
305
|
"""
|
|
302
306
|
|
|
307
|
+
# 呼び出しごとの詳細 (渡した推論の設定・供給元の応答のモデル) も入れる INSERT。record() に reasoning_params か
|
|
308
|
+
# provider_model を渡したときだけ使う (渡さない呼び手は上の _INSERT_SQL のまま = 列の無い台帳でも動く)
|
|
309
|
+
_INSERT_SQL_CALL_DETAIL = """
|
|
310
|
+
INSERT INTO llm_usage_ledger
|
|
311
|
+
(execution_id, message_id, conversation_id, user_id, request_id, endpoint,
|
|
312
|
+
agent_type, level, model, stream, success, usage_status, missing_reason,
|
|
313
|
+
input_tokens, output_tokens, total_tokens, cached_tokens, cost_usd, currency,
|
|
314
|
+
cache_read_tokens, cache_creation_tokens, reasoning_params, provider_model)
|
|
315
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22::jsonb,$23)
|
|
316
|
+
"""
|
|
317
|
+
|
|
303
318
|
# 既存 (列なし) テーブルへの後方互換 migration。INSERT は下の列を前提にするので、既存テーブルには
|
|
304
319
|
# ensure_schema() (cli-api は起動時に呼ぶ) か Alembic で先に当てること。partition 親へ ADD COLUMN すると
|
|
305
320
|
# 全パーティションへ伝播し、metadata-only(PG11+)で即時・無 rewrite。BYO/fresh は
|
|
@@ -308,12 +323,46 @@ LEDGER_MIGRATIONS = (
|
|
|
308
323
|
"ALTER TABLE llm_usage_ledger ADD COLUMN IF NOT EXISTS missing_reason text",
|
|
309
324
|
"ALTER TABLE llm_usage_ledger ADD COLUMN IF NOT EXISTS cache_read_tokens integer",
|
|
310
325
|
"ALTER TABLE llm_usage_ledger ADD COLUMN IF NOT EXISTS cache_creation_tokens integer",
|
|
326
|
+
"ALTER TABLE llm_usage_ledger ADD COLUMN IF NOT EXISTS reasoning_params jsonb",
|
|
327
|
+
"ALTER TABLE llm_usage_ledger ADD COLUMN IF NOT EXISTS provider_model text",
|
|
311
328
|
)
|
|
312
329
|
|
|
313
330
|
# daily_cost の集計軸ホワイトリスト (SQL identifier 注入防止: ユーザー入力を直接埋めない)
|
|
314
331
|
_DAILY_GROUP_COLS = {"model": "model", "user": "user_id", "agent": "agent_type", "day": "day"}
|
|
315
332
|
|
|
316
333
|
|
|
334
|
+
#: JSON の中の NUL 文字のエスケープ (直前のバックスラッシュが奇数個の \u0000。文字としての "\\u0000" は除く)
|
|
335
|
+
_JSON_NUL = re.compile(r"(?<!\\)(?:\\\\)*\\u0000")
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
def _db_text(value: Any) -> Optional[str]:
|
|
339
|
+
"""DB の text にそのまま渡せる空でない文字列なら返す。ほか (文字列でない・空・NUL・UTF-8 にできない) は None。"""
|
|
340
|
+
if not isinstance(value, str) or not value or "\x00" in value:
|
|
341
|
+
return None
|
|
342
|
+
try:
|
|
343
|
+
value.encode("utf-8")
|
|
344
|
+
except UnicodeEncodeError: # 単独のサロゲートなど
|
|
345
|
+
return None
|
|
346
|
+
return value
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def _reasoning_params_json(value: Any) -> Optional[str]:
|
|
350
|
+
"""推論の設定を jsonb に入れる JSON の文字列にする。dict でない・JSON にできない値は None (= NULL)。
|
|
351
|
+
|
|
352
|
+
この欄だけを NULL にし、行 (トークン数・金額) は書く。JSON にできない = 直列化の例外 (直列化できない値・NaN・
|
|
353
|
+
型の混ざったキー・深すぎる入れ子)・UTF-8 にできない文字・NUL 文字 (jsonb は受けない)。
|
|
354
|
+
"""
|
|
355
|
+
if not isinstance(value, dict):
|
|
356
|
+
return None
|
|
357
|
+
try:
|
|
358
|
+
text = json.dumps(value, ensure_ascii=False, sort_keys=True, allow_nan=False)
|
|
359
|
+
except Exception: # noqa: BLE001 - どの直列化の失敗でも、この欄だけを捨てる
|
|
360
|
+
return None
|
|
361
|
+
if _JSON_NUL.search(text) or _db_text(text) is None:
|
|
362
|
+
return None
|
|
363
|
+
return text
|
|
364
|
+
|
|
365
|
+
|
|
317
366
|
class UsageMeter:
|
|
318
367
|
"""LLM 利用量・コストの計測と記録。"""
|
|
319
368
|
|
|
@@ -364,6 +413,7 @@ class UsageMeter:
|
|
|
364
413
|
stream: bool = False, success: bool = True,
|
|
365
414
|
request_id: Optional[str] = None, cost_usd: Optional[float] = None,
|
|
366
415
|
missing_reason: Optional[str] = None,
|
|
416
|
+
reasoning_params: Optional[dict] = None, provider_model: Optional[str] = None,
|
|
367
417
|
fail_safe: bool = True) -> Optional[float]:
|
|
368
418
|
"""1 LLM 呼び出しを台帳へ記録し、算出コスト(USD)を返す。
|
|
369
419
|
|
|
@@ -372,6 +422,9 @@ class UsageMeter:
|
|
|
372
422
|
missing_reason は usage 欠落時の理由(provider_omitted / stream_interrupted 等)。usage が
|
|
373
423
|
取れた行では矛盾を避けるため NULL を保存する(present 行に reason は付けない)。ログだけでなく
|
|
374
424
|
台帳/offline export 側に残し、cost_usd is NULL / usage_status=missing / true-zero を区別可能にする。
|
|
425
|
+
reasoning_params は相手に渡した推論の設定 (dict。``{}`` = 渡していない)、provider_model は供給元の応答の
|
|
426
|
+
モデル名。どちらかを渡したときだけ 2 列を足した INSERT を使う (台帳に reasoning_params jsonb・
|
|
427
|
+
provider_model text の列が要る。ensure_schema() が足す)。両方 None なら従来の INSERT のまま。
|
|
375
428
|
"""
|
|
376
429
|
# fail_safe=True のとき record は決して送出しない(extract/params/INSERT 全体を保護)。
|
|
377
430
|
# cost_fn の失敗だけは個別に握り、token だけは記録できるようにする。
|
|
@@ -395,7 +448,12 @@ class UsageMeter:
|
|
|
395
448
|
u.get("cached_tokens"), round_cost_usd(cost_usd), self._currency,
|
|
396
449
|
_as_int(u.get("cache_read_tokens")), _as_int(u.get("cache_creation_tokens")),
|
|
397
450
|
)
|
|
398
|
-
|
|
451
|
+
if reasoning_params is None and provider_model is None:
|
|
452
|
+
await self._db.execute_query(_INSERT_SQL, params)
|
|
453
|
+
else:
|
|
454
|
+
rp = _reasoning_params_json(reasoning_params)
|
|
455
|
+
pm = _db_text(provider_model)
|
|
456
|
+
await self._db.execute_query(_INSERT_SQL_CALL_DETAIL, params + (rp, pm))
|
|
399
457
|
except Exception as e:
|
|
400
458
|
if not fail_safe:
|
|
401
459
|
raise
|
{agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/azure.py
RENAMED
|
@@ -360,6 +360,7 @@ class AzureBlobStorageClient(StorageClientBase):
|
|
|
360
360
|
self,
|
|
361
361
|
object_name: str,
|
|
362
362
|
download_path: str,
|
|
363
|
+
version_id: Optional[str] = None,
|
|
363
364
|
) -> DownloadResult:
|
|
364
365
|
"""
|
|
365
366
|
ファイルをダウンロード(ストリーミング)
|
|
@@ -370,6 +371,8 @@ class AzureBlobStorageClient(StorageClientBase):
|
|
|
370
371
|
Args:
|
|
371
372
|
object_name: ダウンロードするBlob名
|
|
372
373
|
download_path: ダウンロード先のローカルパス
|
|
374
|
+
version_id: Blob の版 (versionId)。指せばその版を取る (無い版は BLOB_NOT_FOUND)。
|
|
375
|
+
省略時は最新
|
|
373
376
|
|
|
374
377
|
Returns:
|
|
375
378
|
DownloadResult: ダウンロード結果
|
|
@@ -400,12 +403,22 @@ class AzureBlobStorageClient(StorageClientBase):
|
|
|
400
403
|
error_code="STORAGE_NOT_ENABLED",
|
|
401
404
|
)
|
|
402
405
|
|
|
406
|
+
if version_id is not None and not version_id.strip():
|
|
407
|
+
return DownloadResult(
|
|
408
|
+
success=False,
|
|
409
|
+
object_name=object_name,
|
|
410
|
+
error=f"Blob not found: {object_name}",
|
|
411
|
+
error_code="BLOB_NOT_FOUND",
|
|
412
|
+
)
|
|
413
|
+
|
|
403
414
|
try:
|
|
404
415
|
blob_client = self._get_blob_client(object_name)
|
|
416
|
+
# 版を指すときだけ version_id を渡す (省略時は今までと同じ呼び方で最新)
|
|
417
|
+
version_kwargs = {"version_id": version_id} if version_id is not None else {}
|
|
405
418
|
|
|
406
419
|
# 存在確認
|
|
407
420
|
exists = await asyncio.get_event_loop().run_in_executor(
|
|
408
|
-
None, blob_client.exists
|
|
421
|
+
None, lambda: blob_client.exists(**version_kwargs)
|
|
409
422
|
)
|
|
410
423
|
if not exists:
|
|
411
424
|
return DownloadResult(
|
|
@@ -422,7 +435,7 @@ class AzureBlobStorageClient(StorageClientBase):
|
|
|
422
435
|
# ストリーミングダウンロード(メモリ効率化)
|
|
423
436
|
def _streaming_download():
|
|
424
437
|
with open(download_path_obj, 'wb') as f:
|
|
425
|
-
download_stream = blob_client.download_blob()
|
|
438
|
+
download_stream = blob_client.download_blob(**version_kwargs)
|
|
426
439
|
# chunks()でチャンク単位でダウンロード
|
|
427
440
|
for chunk in download_stream.chunks():
|
|
428
441
|
f.write(chunk)
|
{agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/base.py
RENAMED
|
@@ -470,8 +470,9 @@ class StorageClientProtocol(Protocol):
|
|
|
470
470
|
self,
|
|
471
471
|
object_name: str,
|
|
472
472
|
download_path: str,
|
|
473
|
+
version_id: Optional[str] = None,
|
|
473
474
|
) -> DownloadResult:
|
|
474
|
-
"""
|
|
475
|
+
"""ファイルをダウンロード(version_id を指せばその版。無ければ最新)"""
|
|
475
476
|
...
|
|
476
477
|
|
|
477
478
|
async def list_objects(
|
|
@@ -640,6 +641,7 @@ class StorageClientBase(ABC):
|
|
|
640
641
|
self,
|
|
641
642
|
object_name: str,
|
|
642
643
|
download_path: str,
|
|
644
|
+
version_id: Optional[str] = None,
|
|
643
645
|
) -> DownloadResult:
|
|
644
646
|
pass
|
|
645
647
|
|
{agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/gcs.py
RENAMED
|
@@ -289,6 +289,7 @@ class GCSStorageClient(StorageClientBase):
|
|
|
289
289
|
self,
|
|
290
290
|
object_name: str,
|
|
291
291
|
download_path: str,
|
|
292
|
+
version_id: Optional[str] = None,
|
|
292
293
|
) -> DownloadResult:
|
|
293
294
|
"""
|
|
294
295
|
ファイルをGCSからダウンロード
|
|
@@ -296,6 +297,8 @@ class GCSStorageClient(StorageClientBase):
|
|
|
296
297
|
Args:
|
|
297
298
|
object_name: ダウンロードするオブジェクト名
|
|
298
299
|
download_path: ダウンロード先のローカルパス
|
|
300
|
+
version_id: オブジェクトの版 (generation の数字の文字列)。指せばその版を取る
|
|
301
|
+
(無い版・数字でない値は OBJECT_NOT_FOUND)。省略時は最新
|
|
299
302
|
|
|
300
303
|
Returns:
|
|
301
304
|
DownloadResult: ダウンロード結果
|
|
@@ -307,9 +310,22 @@ class GCSStorageClient(StorageClientBase):
|
|
|
307
310
|
error_code="STORAGE_NOT_ENABLED",
|
|
308
311
|
)
|
|
309
312
|
|
|
313
|
+
generation: Optional[int] = None
|
|
314
|
+
if version_id is not None:
|
|
315
|
+
try:
|
|
316
|
+
generation = int(version_id)
|
|
317
|
+
except (TypeError, ValueError):
|
|
318
|
+
return DownloadResult(
|
|
319
|
+
success=False,
|
|
320
|
+
object_name=object_name,
|
|
321
|
+
error=f"Object not found: {object_name}",
|
|
322
|
+
error_code="OBJECT_NOT_FOUND",
|
|
323
|
+
)
|
|
324
|
+
|
|
310
325
|
try:
|
|
311
326
|
bucket = self._get_bucket()
|
|
312
|
-
|
|
327
|
+
# 版を指すときだけ generation を渡す (省略時は今までと同じ呼び方で最新)
|
|
328
|
+
blob = bucket.blob(object_name, generation=generation) if generation is not None else bucket.blob(object_name)
|
|
313
329
|
|
|
314
330
|
exists = await asyncio.get_running_loop().run_in_executor(
|
|
315
331
|
None, blob.exists
|
{agenticstar_platform-3.2.3 → agenticstar_platform-3.4.0}/agenticstar_platform/storage/s3.py
RENAMED
|
@@ -296,6 +296,7 @@ class S3StorageClient(StorageClientBase):
|
|
|
296
296
|
self,
|
|
297
297
|
object_name: str,
|
|
298
298
|
download_path: str,
|
|
299
|
+
version_id: Optional[str] = None,
|
|
299
300
|
) -> DownloadResult:
|
|
300
301
|
"""
|
|
301
302
|
ファイルをS3からダウンロード(ストリーミング)
|
|
@@ -303,6 +304,8 @@ class S3StorageClient(StorageClientBase):
|
|
|
303
304
|
Args:
|
|
304
305
|
object_name: ダウンロードするオブジェクト名
|
|
305
306
|
download_path: ダウンロード先のローカルパス
|
|
307
|
+
version_id: オブジェクトの版 (VersionId)。指せばその版を取る (無い版は OBJECT_NOT_FOUND)。
|
|
308
|
+
省略時は最新
|
|
306
309
|
|
|
307
310
|
Returns:
|
|
308
311
|
DownloadResult: ダウンロード結果
|
|
@@ -314,9 +317,20 @@ class S3StorageClient(StorageClientBase):
|
|
|
314
317
|
error_code="STORAGE_NOT_ENABLED",
|
|
315
318
|
)
|
|
316
319
|
|
|
320
|
+
if version_id is not None and not version_id.strip():
|
|
321
|
+
return DownloadResult(
|
|
322
|
+
success=False,
|
|
323
|
+
object_name=object_name,
|
|
324
|
+
error=f"Object not found: {object_name}",
|
|
325
|
+
error_code="OBJECT_NOT_FOUND",
|
|
326
|
+
)
|
|
327
|
+
|
|
317
328
|
try:
|
|
318
|
-
# 存在確認
|
|
319
|
-
|
|
329
|
+
# 存在確認 (版を指さないときは今までどおり公開の object_exists を呼ぶ)
|
|
330
|
+
if version_id is None:
|
|
331
|
+
exists = await self.object_exists(object_name)
|
|
332
|
+
else:
|
|
333
|
+
exists = await self._object_exists(object_name, version_id)
|
|
320
334
|
if not exists:
|
|
321
335
|
return DownloadResult(
|
|
322
336
|
success=False,
|
|
@@ -328,12 +342,15 @@ class S3StorageClient(StorageClientBase):
|
|
|
328
342
|
download_path_obj = Path(download_path)
|
|
329
343
|
download_path_obj.parent.mkdir(parents=True, exist_ok=True)
|
|
330
344
|
|
|
345
|
+
# 版を指すときだけ ExtraArgs を渡す (省略時は今までと同じ呼び方で最新)
|
|
346
|
+
extra = {"ExtraArgs": {"VersionId": version_id}} if version_id is not None else {}
|
|
331
347
|
await asyncio.get_running_loop().run_in_executor(
|
|
332
348
|
None,
|
|
333
349
|
lambda: self._s3_client.download_file(
|
|
334
350
|
self.bucket_name,
|
|
335
351
|
object_name,
|
|
336
352
|
str(download_path_obj),
|
|
353
|
+
**extra,
|
|
337
354
|
)
|
|
338
355
|
)
|
|
339
356
|
|
|
@@ -440,16 +457,20 @@ class S3StorageClient(StorageClientBase):
|
|
|
440
457
|
|
|
441
458
|
async def object_exists(self, object_name: str) -> bool:
|
|
442
459
|
"""オブジェクトの存在確認"""
|
|
460
|
+
return await self._object_exists(object_name)
|
|
461
|
+
|
|
462
|
+
async def _object_exists(self, object_name: str, version_id: Optional[str] = None) -> bool:
|
|
463
|
+
"""オブジェクト (version_id を指せばその版) の存在確認"""
|
|
443
464
|
if not self._enabled:
|
|
444
465
|
return False
|
|
445
466
|
|
|
467
|
+
head_args: Dict[str, Any] = {"Bucket": self.bucket_name, "Key": object_name}
|
|
468
|
+
if version_id is not None:
|
|
469
|
+
head_args["VersionId"] = version_id
|
|
446
470
|
try:
|
|
447
471
|
await asyncio.get_running_loop().run_in_executor(
|
|
448
472
|
None,
|
|
449
|
-
lambda: self._s3_client.head_object(
|
|
450
|
-
Bucket=self.bucket_name,
|
|
451
|
-
Key=object_name,
|
|
452
|
-
)
|
|
473
|
+
lambda: self._s3_client.head_object(**head_args)
|
|
453
474
|
)
|
|
454
475
|
return True
|
|
455
476
|
except ClientError as e:
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""ConfigAccess.get_system_settings は連結順序 (priority) の昇順で返す (3.4 10 §14.1 の 188)。
|
|
2
|
+
|
|
3
|
+
呼び手は返った順に共通の指示をつなぐので、executor (!656) と cli-api (llm_proxy) と同じく
|
|
4
|
+
管理コンソールの連結順序の昇順で並べる。全体 (organization_id IS NULL) の行だけを読むのは今のまま。
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
|
|
9
|
+
from agenticstar_platform.db.config_access import ConfigAccess
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FakeDB:
|
|
13
|
+
"""execute_query に渡った文を控え、渡された行をそのままの順で返す最小の代わり (SQL は実行しない)。"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, rows):
|
|
16
|
+
self.rows = rows
|
|
17
|
+
self.queries = []
|
|
18
|
+
|
|
19
|
+
async def execute_query(self, query, params=()):
|
|
20
|
+
self.queries.append(query)
|
|
21
|
+
return {"success": True, "data": list(self.rows)}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.mark.asyncio
|
|
25
|
+
async def test_system_settings_query_orders_by_priority_asc():
|
|
26
|
+
db = FakeDB([{"user_prompt": "b", "guardrail_text": "", "is_active": True, "priority": 2}])
|
|
27
|
+
result = await ConfigAccess(db).get_system_settings()
|
|
28
|
+
|
|
29
|
+
assert result["success"] is True
|
|
30
|
+
query = " ".join(db.queries[0].split())
|
|
31
|
+
assert "WHERE organization_id IS NULL AND is_active = true" in query
|
|
32
|
+
assert query.endswith("ORDER BY priority ASC")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.mark.asyncio
|
|
36
|
+
async def test_system_settings_returns_rows_in_db_order():
|
|
37
|
+
# 並べるのは DB (ORDER BY) で、SDK は受け取った順と値を変えない (Python 側で並べ直さない)
|
|
38
|
+
rows = [
|
|
39
|
+
{"user_prompt": "late", "guardrail_text": "g1", "is_active": True, "priority": 5},
|
|
40
|
+
{"user_prompt": "early", "guardrail_text": "", "is_active": True, "priority": 1},
|
|
41
|
+
{"user_prompt": "none", "guardrail_text": "", "is_active": True, "priority": None},
|
|
42
|
+
]
|
|
43
|
+
result = await ConfigAccess(FakeDB(rows)).get_system_settings()
|
|
44
|
+
|
|
45
|
+
assert result["data"] == rows
|