datarobot_genai.dragent.agent_card_registry
agent_card_registry
Client for the central DataRobot agent card registry.
The central registry provides a tenant-scoped list of agent cards that requires
only standard DataRobot API-token authentication (DATAROBOT_API_TOKEN).
This avoids the chicken-and-egg problem where an individual agent's card
endpoint is behind per-agent AuthN/AuthZ.
The :class:AgentCardRegistry supports batch fetching so that many
function groups sharing the same workflow can resolve all their cards in a
minimum number of HTTP round-trips instead of N+1 individual requests.
Lookups can be registered before the first fetch so that get()
automatically triggers a single batch prefetch for all pending IDs on its
first invocation — no explicit prefetch() call required.
.. note::
The registry issues one HTTP call per ID kind — deployment, external
and workload IDs are never mixed in a single request. Sending
deploymentIds together with workloadIds is rejected by the API with
HTTP 400 (the two are mutually exclusive), and combining either with
externalIds AND-matches, returning empty results.
.. note::
The API caps each ID parameter at 20 values, so :meth:AgentCardRegistry._fetch
splits longer ID lists into chunks of 20 and accumulates the entries before
parsing them as one result set.
DataRobotRegistrySettings
Bases: DataRobotAppFrameworkBaseSettings
DataRobot endpoint setting for the central agent card registry.
Loads DATAROBOT_ENDPOINT from env vars (including Runtime Parameters),
.env, file secrets, or Pulumi config using the standard
:class:DataRobotAppFrameworkBaseSettings priority chain.
Deliberately not read through resolve_config().resolve_datarobot_endpoint():
that resolver substitutes the public app.datarobot.com default when nothing
is configured, and this lookup sends the API token to whatever host it resolves,
so an unset endpoint has to stay distinguishable from a configured one. The API
token itself does come from the global config; see :func:_resolve_settings.
Source code in datarobot_genai/dragent/agent_card_registry.py
AgentCardRegistryConfig
Bases: DataRobotAppFrameworkBaseSettings
Configuration for the agent card registry cache.
Controllable via environment variables (prefix-free, following the
standard :class:DataRobotAppFrameworkBaseSettings resolution chain).
Set AGENT_CARD_REGISTRY_CACHE_TTL=0 to disable caching entirely
(every get() triggers a fresh HTTP fetch).
AGENT_CARD_REGISTRY_SOFT_CACHE_TTL controls when cached cards are
considered fresh (skip registry fetch). AGENT_CARD_REGISTRY_CACHE_TTL
is the hard bound for stale-if-error when the registry is unreachable.
When soft TTL is unset it defaults to the hard TTL.
Source code in datarobot_genai/dragent/agent_card_registry.py
AgentCardRegistryError
ParsedRegistryCards
Bases: NamedTuple
Parsed registry response with lookup key types for cache indexing.
Source code in datarobot_genai/dragent/agent_card_registry.py
AgentCardRegistry
Batch-capable, TTL-cached client for the central agent card registry.
IDs are register()-ed synchronously at config-parse time (no I/O).
The first get() flushes all pending IDs in ≤3 HTTP calls — one per ID
kind (deployment, external, workload), never mixed in a single request, plus
one extra call per 20 IDs of the same kind (the API's per-parameter cap).
Subsequent get() calls hit the in-memory cache until the soft TTL
(AGENT_CARD_REGISTRY_SOFT_CACHE_TTL, defaulting to the hard TTL) expires.
When a refresh fails, a cached card may still be returned while it remains
within AGENT_CARD_REGISTRY_CACHE_TTL (the hard TTL / stale-if-error bound).
Source code in datarobot_genai/dragent/agent_card_registry.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 | |
register
register(*, deployment_id: str | None = None, external_id: str | None = None, workload_id: str | None = None) -> None
Declare intent to look up an agent card.
Call this at config-parse/validation time so that the first
:meth:get can batch all pending IDs into a single prefetch.
Exactly one of deployment_id, external_id or workload_id
must be given.
Source code in datarobot_genai/dragent/agent_card_registry.py
has_registered_lookups
Return whether any registry lookup IDs were registered.
Source code in datarobot_genai/dragent/agent_card_registry.py
prefetch
async
prefetch(*, deployment_ids: list[str] | None = None, external_ids: list[str] | None = None, workload_ids: list[str] | None = None) -> None
Batch-fetch and cache agent cards in a minimum number of HTTP calls.
Issues separate requests per ID kind: deploymentIds together
with workloadIds is rejected with HTTP 400, and either combined with
externalIds AND-matches and returns nothing.
Already-cached (non-expired) IDs are skipped.
Parameters
deployment_ids: Deployment IDs to prefetch. external_ids: External IDs to prefetch. workload_ids: Workload IDs to prefetch.
Source code in datarobot_genai/dragent/agent_card_registry.py
refresh_all_registered
async
Re-fetch registered IDs whose cache entries are past the soft TTL.
Existing cache entries are left in place on failure so stale-if-error can continue serving them during registry outages. Errors propagate so the background refresh loop can log once and back off.
Source code in datarobot_genai/dragent/agent_card_registry.py
get
async
get(*, deployment_id: str | None = None, external_id: str | None = None, workload_id: str | None = None, auth_headers: dict[str, str] | None = None) -> AgentCard
Return a single agent card, using the cache or fetching on demand.
On the first call, all IDs previously passed to :meth:register
are batch-fetched in a single prefetch (one HTTP call per ID kind).
Subsequent calls for already-cached, non-expired cards are instant.
Exactly one of deployment_id, external_id or workload_id
must be provided.
Pass auth_headers to fetch a miss as the caller; the owner key is the fallback.
Raises
AgentCardRegistryError If the card cannot be found or the request fails.
Source code in datarobot_genai/dragent/agent_card_registry.py
get_default_registry
async
Return the module-level :class:AgentCardRegistry singleton.
Created lazily on first access. Credentials are resolved from
:class:DataRobotRegistrySettings at instantiation time. On enclave
workloads, L2 MemorySpace provisioning runs on this event loop before the
singleton is constructed so the cache backend is not stuck on L1-only.
Source code in datarobot_genai/dragent/agent_card_registry.py
get_default_registry_sync
Return the singleton, creating it if needed (synchronous).
Safe to call from pydantic validators and other sync contexts
(e.g. config-parse time) because :class:AgentCardRegistry.__init__
does no I/O. If import-time bootstrap already provisioned the L2
MemorySpace, the constructor attaches write-behind even when this is
called on a running event loop.