Skip to content

[chore] Promote the field-mapping resolver into the SDK#4739

Draft
junaway wants to merge 1 commit into
wp1-events-catalogfrom
wp2-resolver-promote
Draft

[chore] Promote the field-mapping resolver into the SDK#4739
junaway wants to merge 1 commit into
wp1-events-catalogfrom
wp2-resolver-promote

Conversation

@junaway

@junaway junaway commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Context

Webhooks resolve a payload-mapping template (turn an event payload into the fields a destination expects) inside core/webhooks/delivery.py. Triggers need the exact same resolution to map a provider event into workflow inputs. Rather than copy the logic, we promote it to the SDK so both domains call one implementation.

Changes

Moves the field-mapping resolver into the SDK as agenta.sdk.utils.resolvers.resolve_target_fields:

  • The resolver now lives in sdks/python/agenta/sdk/utils/resolvers.py.
  • core/webhooks/delivery.py calls resolve_target_fields instead of its own inline copy. Behavior is unchanged; the webhook unit tests still pass against the promoted function.
  • Minor cleanup in core/tools/ (interfaces and service) that rode along with the extraction.

No behavior change. This is a refactor that gives the later triggers dispatch lane a shared resolver to map events to workflow inputs.

Tests / notes

  • tests/pytest/unit/webhooks/test_webhooks_tasks.py exercises the resolver through the webhook delivery path and passes.

Copilot AI review requested due to automatic review settings June 18, 2026 16:14
@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jun 18, 2026 4:32pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2dc4d9c9-5f14-403a-ac65-8e778aca9ab7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wp2-resolver-promote

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@junaway junaway changed the base branch from main to wp1-events-catalog June 18, 2026 16:15

Copilot AI left a comment

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.

⚠️ Not ready to approve

Provider lookup logic in both tools/triggers services is currently incorrect (enum-vs-str comparison) and can cause valid provider endpoints to return 404/500.

Pull request overview

This PR refactors webhook payload field resolution by moving the “resolve template leaves” logic into the shared Python SDK, and introduces new backend domains for Connections (shared gateway_connections table) and Triggers (read-only Composio event catalog), including API routing, persistence, and acceptance tests.

Changes:

  • Added resolve_target_fields (and shared depth cap) to the Python SDK and updated webhook delivery to use it.
  • Split tool connection auth into a dedicated connections domain backed by the renamed gateway_connections table (incl. migration + DAO/service wiring).
  • Added triggers catalog domain + FastAPI router + Composio adapter, plus OSS/EE acceptance tests and EE permissions.
File summaries
File Description
sdks/python/agenta/sdk/utils/resolvers.py Adds MAX_RESOLVE_DEPTH and resolve_target_fields for reusable selector-leaf resolution.
api/oss/tests/pytest/unit/webhooks/test_webhooks_tasks.py Updates unit tests to use SDK resolver helpers.
api/oss/tests/pytest/unit/models/test_lifecycle_conventions.py Updates lifecycle conventions list to reference new connections DBEs module.
api/oss/tests/pytest/acceptance/triggers/test_triggers_catalog.py Adds OSS acceptance coverage for triggers catalog endpoints.
api/oss/tests/pytest/acceptance/triggers/init.py Initializes OSS triggers acceptance test package.
api/oss/tests/pytest/acceptance/tools/test_tools_connections.py Adds OSS acceptance coverage pinning /tools/connections contract.
api/oss/src/dbs/postgres/triggers/init.py Initializes triggers DB package placeholder.
api/oss/src/dbs/postgres/connections/mappings.py Maps connection DTOs to/from the new ConnectionDBE.
api/oss/src/dbs/postgres/connections/dbes.py Introduces ConnectionDBE for gateway_connections.
api/oss/src/dbs/postgres/connections/dao.py Implements ConnectionsDAO CRUD/query operations for gateway connections.
api/oss/src/dbs/postgres/connections/init.py Initializes connections DB package.
api/oss/src/core/webhooks/delivery.py Switches webhook payload building to resolve_target_fields.
api/oss/src/core/triggers/service.py Adds triggers domain service for provider/event catalog orchestration.
api/oss/src/core/triggers/registry.py Adds provider-keyed triggers adapter registry.
api/oss/src/core/triggers/providers/composio/catalog.py Implements Composio triggers catalog HTTP client (list/get events).
api/oss/src/core/triggers/providers/composio/adapter.py Adds Composio triggers adapter implementing the triggers gateway interface.
api/oss/src/core/triggers/providers/composio/init.py Lazy-import wrapper for Composio triggers adapter.
api/oss/src/core/triggers/providers/init.py Initializes triggers providers package.
api/oss/src/core/triggers/interfaces.py Defines TriggersGatewayInterface contract (catalog + subscription verbs).
api/oss/src/core/triggers/exceptions.py Adds triggers-domain exception hierarchy.
api/oss/src/core/triggers/dtos.py Adds triggers catalog DTOs (providers/events).
api/oss/src/core/triggers/init.py Initializes triggers core package.
api/oss/src/core/tools/service.py Refactors tools service to delegate connection ops to ConnectionsService.
api/oss/src/core/tools/providers/composio/adapter.py Removes connection-auth responsibilities from tools adapter (execution-only).
api/oss/src/core/tools/interfaces.py Simplifies tools gateway interface to catalog + execution only.
api/oss/src/core/tools/dtos.py Removes tool-connection DTOs now owned by connections domain.
api/oss/src/core/connections/utils.py Updates connections OAuth state utility module header comment.
api/oss/src/core/connections/service.py Adds ConnectionsService owning gateway_connections lifecycle/auth flows.
api/oss/src/core/connections/registry.py Adds provider-keyed connections adapter registry.
api/oss/src/core/connections/providers/composio/adapter.py Adds Composio connections auth adapter (init/status/refresh/revoke).
api/oss/src/core/connections/providers/composio/init.py Lazy-import wrapper for Composio connections adapter.
api/oss/src/core/connections/providers/init.py Initializes connections providers package.
api/oss/src/core/connections/interfaces.py Defines DAO + gateway interfaces for connections domain.
api/oss/src/core/connections/exceptions.py Adds connections-domain exception hierarchy.
api/oss/src/core/connections/dtos.py Adds connections DTOs (Connection/ConnectionCreate + adapter-level DTOs).
api/oss/src/core/connections/init.py Initializes connections core package.
api/oss/src/apis/fastapi/triggers/router.py Adds FastAPI triggers catalog router (OSS/EE permission gating + caching).
api/oss/src/apis/fastapi/triggers/models.py Adds FastAPI response models for triggers catalog.
api/oss/src/apis/fastapi/triggers/init.py Initializes triggers FastAPI API package.
api/oss/src/apis/fastapi/tools/router.py Switches OAuth state decode import to connections utils.
api/oss/src/apis/fastapi/tools/models.py Swaps tool connection request/response types to connections-domain DTOs.
api/oss/databases/postgres/migrations/core_oss/versions/oss000000002_rename_tool_connections_to_gateway_connections.py Renames tool_connectionsgateway_connections and renames related constraint/index.
api/entrypoints/routers.py Wires new connections + triggers services/routers and adapter shutdown hooks.
api/ee/tests/pytest/acceptance/triggers/test_triggers_catalog.py Adds EE acceptance coverage for triggers catalog (permission + live Composio gating).
api/ee/tests/pytest/acceptance/triggers/init.py Initializes EE triggers acceptance test package.
api/ee/tests/pytest/acceptance/tools/test_tools_connections.py Adds EE acceptance coverage for /tools/connections contract.
api/ee/tests/pytest/acceptance/tools/init.py Initializes EE tools acceptance test package.
api/ee/src/core/access/permissions/types.py Adds VIEW/EDIT/RUN_TRIGGERS permissions and includes VIEW_TRIGGERS in defaults.

Copilot's findings

  • Files reviewed: 3/5 changed files
  • Comments generated: 2

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +51 to +56
adapter = self.adapter_registry.get(provider_key)
providers = await adapter.list_providers()
for p in providers:
if p.key == provider_key:
return p
return None
# ---------------------------------------------------------------------------


class TestResolvePayloadFields:
Move resolve_payload_fields out of core/webhooks/delivery.py into the SDK as
resolve_target_fields (next to resolve_json_selector) so triggers and webhooks
share it without a cross-domain import. Pure move + rename, no behavior change;
its live consumer today is webhooks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@junaway junaway force-pushed the wp1-events-catalog branch from aabbf52 to 87e5041 Compare June 18, 2026 16:31
@junaway junaway force-pushed the wp2-resolver-promote branch from fd88cb9 to b3787e3 Compare June 18, 2026 16:31
@jp-agenta jp-agenta changed the title [chore] Clean up event fields resolver [chore] Promote the field-mapping resolver into the SDK Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants