agentpay/symfony-bridge

Symfony bundle for AgentPay PHP SDK integration.

Maintainers

Package info

bitbucket.org/agentpay/symfony-bridge

Type:symfony-bundle

pkg:composer/agentpay/symfony-bridge

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

v0.1.2 2026-09-02 05:25 UTC

This package is not auto-updated.

Last update: 2026-09-02 05:26:33 UTC


README

Symfony bundle for wiring agentpay/php-sdk into Symfony applications.

Configuration

Copy config/packages/agentpay.yaml into your Symfony application and adjust the env vars.

agentpay:
  enabled: '%env(bool:AGENTPAY_ENABLED)%'
  base_url: '%env(AGENTPAY_BASE_URL)%'
  api_key: '%env(AGENTPAY_API_KEY)%'
  organization_id: '%env(AGENTPAY_ORGANIZATION_ID)%'
  default_agent:
    external_id: 'symfony-app'
    name: 'Symfony Application'
  privacy:
    allow_only_safe_metadata: true
  retry:
    max_attempts: 3
  buffer:
    enabled: true
    path: '%kernel.cache_dir%/agentpay/events.jsonl'
  integrations:
    symfony_ai:
      enabled: true
      authorize_spend: true
      send_token_usage: true
      send_prompts: false
      send_responses: false

Commands

bin/console agentpay:ping
bin/console agentpay:test-event

Telemetry Helper

Inject AgentPay\Symfony\Telemetry\AgentPayTelemetry when application code only needs common session/task events:

use AgentPay\Enum\TaskType;
use AgentPay\Enum\TaskTypeSource;
use AgentPay\Symfony\Telemetry\AgentPayTelemetry;

final readonly class AiWorkflow
{
    public function __construct(private AgentPayTelemetry $agentPayTelemetry)
    {
    }

    public function run(): void
    {
        $this->agentPayTelemetry->sessionStarted('ses_123', 'Demo session');

        $this->agentPayTelemetry->taskStarted(
            sessionExternalId: 'ses_123',
            taskExternalId: 'task_123',
            taskType: TaskType::Feature,
            taskTypeSource: TaskTypeSource::Explicit,
            taskTypeConfidence: 1.0,
        );

        $this->agentPayTelemetry->taskCompleted(
            sessionExternalId: 'ses_123',
            taskExternalId: 'task_123',
            taskType: TaskType::Feature,
            taskTypeSource: TaskTypeSource::Explicit,
            taskTypeConfidence: 1.0,
        );
    }
}

Symfony AI

When symfony/ai-bundle is installed, services tagged as ai.agent are decorated with AgentPay telemetry. The decorator records safe operational metadata and token usage from Symfony AI result metadata. It does not send prompts or model responses.

Per-call AgentPay context can be passed through Symfony AI options:

$agent->call('user prompt', [
    'agentpay_session_id' => 'ses_123',
    'agentpay_task_id' => 'task_123',
    'agentpay_provider' => 'openai',
    'agentpay_model' => 'gpt-4o-mini',
    'agentpay_task_type' => 'feature',
    'agentpay_task_type_source' => 'explicit',
    'agentpay_task_type_confidence' => 1.0,
    'agentpay_metadata' => [
        'repository' => 'agentpay/app',
        'branch' => 'feature/demo',
    ],
]);

If agentpay_estimated_cost_usd is provided and authorize_spend is enabled, the bridge calls AgentPay AuthorizeSpend before executing the Symfony AI call. BLOCK and REQUIRE_APPROVAL stop the call by throwing AgentPaySymfonyAiException.