AgentCore
Core SDK for the AI Agent Platform.
Functional architecture: AgentCore stores only the processing pipeline (plugins via wrappers), all transformations are pure functions that take session/config and return new objects.
Examples:
Basic non-streaming usage:
from agent_core import AgentCore
from plugins.openai_provider import OpenAICompatibleProvider
core = AgentCore()
core.register_provider(OpenAICompatibleProvider)
session = core.create_session()
session = core.add_message(session, "user", "Hello!")
config = {
"provider": "openai_compatible",
"model": "gpt-4o",
"base_url": "https://api.openai.com/v1",
"api_key": "sk-...",
}
session, finals = core.send_request(session, config)
print(finals[-1]["content"]) # Assistant reply
Streaming usage:
```python for chunk in core.send_request_stream(session, config): if chunk["type"] == "partial": print(chunk["message"]["content"], end="", flush=True) elif chunk["type"] == "final": session = chunk["session"] print("
[Done]") ```
Tool schemas and execution:
```python
tool_schemas = core.get_tool_schemas(config)
# Execute tool calls the model asked for (application loop)
tool_results = core.execute_tool_calls(tool_calls, config)
for msg in tool_results:
session = core.add_message(session, msg["role"], msg["content"], msg.get("metadata"))
```
AgentCore
AgentCore(model_cache=None)
Stateless processing pipeline for AI Agent Platform.
Stores registered plugin wrappers (processing logic), not runtime state. All methods are pure functions that take session/config as parameters. The application layer manages sessions and configuration.
Initialize core with empty plugin pipeline.
Loggers are initialized lazily so that structlog configuration can be customized by applications before any loggers are created.
Source code in core/python/agent_core/core.py
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 | |
add_message
add_message(
session,
role,
content,
metadata=None,
config=None,
*,
multipart_content=None,
after_index=None,
context=None,
tool_result=None
)
Add a message to the session (pure function).
When session.metadata contains provider-native history (native_messages) and a provider is registered, converts the newly added message to provider-native format and appends it to the stored native history. Updates verification data for integrity checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Current session. |
required |
role
|
MessageRole
|
Message role ("system", "user", "assistant", or "tool"). |
required |
content
|
Any
|
Message content. |
required |
metadata
|
Optional[Dict[str, Any]]
|
Optional per-message metadata.
Note: when provider-native history is enabled (session metadata
contains |
None
|
config
|
Optional[Dict[str, Any]]
|
Optional configuration used to resolve provider and plugins. |
None
|
tool_result
|
Optional[Dict[str, Any]]
|
Optional structured tool result payload for this message. This is the canonical structured representation for tool messages and may be consumed by providers when appending to provider-native history. |
None
|
after_index
|
Optional[int]
|
Optional index after which to insert the message.
When |
None
|
Returns:
| Type | Description |
|---|---|
Session
|
New Session with the message added (immutable update). |
Source code in core/python/agent_core/core.py
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 | |
apply_feature_completion
apply_feature_completion(config, text, completion)
Ask features to transform an accepted completion into a snippet.
Iterates over registered feature plugins and calls their
:meth:apply_completion hooks in registration order. The first
non-empty string returned is used as the replacement snippet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict[str, Any]
|
Application configuration for the current agent or request. |
required |
text
|
str
|
Full buffer text after the completion has been applied. |
required |
completion
|
Dict[str, Any]
|
Completion descriptor dict that was accepted, as
previously returned by :meth: |
required |
Returns:
| Type | Description |
|---|---|
str
|
Replacement snippet string, or an empty string when no feature |
str
|
chooses to handle the completion. |
Source code in core/python/agent_core/core.py
3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 | |
core_messages_to_native
core_messages_to_native(
core_messages, config, *, context=None
)
Convert core-shaped messages into provider-native messages.
This is a thin public wrapper around the normal provider/extension/ feature conversion path. It is intended for request-time features and actions that need to synthesize a core message and append its provider-native form to an in-flight request without re-implementing provider-specific message shaping.
Source code in core/python/agent_core/core.py
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 | |
create_session
create_session(session_id=None)
Create a new empty session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
Optional[str]
|
Optional session identifier. Auto-generated if omitted. |
None
|
Returns:
| Type | Description |
|---|---|
Session
|
New immutable Session instance with no messages. |
Source code in core/python/agent_core/core.py
655 656 657 658 659 660 661 662 663 664 665 666 | |
discover_and_register
discover_and_register(modules)
Discover plugins from Python modules and register them by duck typing.
Plugin type is inferred based on the presence of methods on the class: - Provider: has 'stream_api' or 'call_api' - Provider Extension: has 'process_chunk' (and no tool/provider I/O methods) - Tool: has 'get_tool_schemas' and 'execute_tool' - Feature: otherwise
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
modules
|
List[str]
|
List of import paths to scan for plugin classes. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, List[str]]
|
Summary of registered plugin names by type with keys: providers, features, tools, extensions. |
Source code in core/python/agent_core/core.py
4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 | |
execute_lifecycle_actions
execute_lifecycle_actions(
session, config, trigger, *, context=None
)
Execute all extension/feature actions whose trigger matches trigger.
Source code in core/python/agent_core/core.py
3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 | |
execute_response_lifecycle_actions
execute_response_lifecycle_actions(
session,
config,
trigger,
*,
provider,
features,
state,
final_messages,
native_messages,
native_final_messages,
stream,
turn_native_start_index,
request_context,
extra_context=None
)
Execute core-owned response lifecycles before finals are emitted.
Source code in core/python/agent_core/core.py
3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 | |
execute_session_action
execute_session_action(
session,
config,
plugin_id,
action_id,
params,
context=None,
)
Execute a generic session-scoped extension or feature action.
Source code in core/python/agent_core/core.py
3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 | |
execute_tool_calls
execute_tool_calls(tool_calls, config, *, context=None)
Return only the final core tool message per tool call.
This is a compatibility wrapper around :meth:iter_tool_messages
that ignores partial payloads and keeps only the last final tool
message for each call. When a streaming tool yields no items for a
call, a synthetic error message is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_calls
|
List[Dict[str, Any]]
|
List of tool call dictionaries to execute. |
required |
config
|
Dict[str, Any]
|
Current resolved request configuration. |
required |
context
|
Optional[Dict[str, Any]]
|
Optional context for tool execution. Passed through to
:meth: |
None
|
Source code in core/python/agent_core/core.py
4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 | |
export_session
export_session(session, format='json')
Export session to a serialized string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Session to serialize. |
required |
format
|
str
|
Export format. Only "json" is supported. |
'json'
|
Returns:
| Type | Description |
|---|---|
str
|
Serialized string representing the session. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the format is not supported. |
Source code in core/python/agent_core/core.py
4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 | |
extract_tool_calls_from_messages
extract_tool_calls_from_messages(messages)
Extract tool-call dictionaries from assistant message metadata.
Source code in core/python/agent_core/core.py
4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 | |
fork_session
fork_session(
session, config=None, *, upto_index, new_session_id=None
)
Convenience helper to fork a session up to upto_index.
Source code in core/python/agent_core/core.py
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 | |
format_tool_call_preview
format_tool_call_preview(tool_call, config)
Return a preview record for a single tool call.
Source code in core/python/agent_core/core.py
4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 | |
format_tool_call_previews
format_tool_call_previews(tool_calls, config)
Return preview records for all supplied tool calls.
Source code in core/python/agent_core/core.py
4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 | |
get_available_tools
get_available_tools(config)
Get the full available tool catalog for a config before filtering.
Source code in core/python/agent_core/core.py
3855 3856 3857 | |
get_completions
get_completions(config, text)
Collect completion suggestions from registered feature plugins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Dict[str, Any]
|
Application configuration for the current agent or request. |
required |
text
|
str
|
Full text before the cursor (for example, the current input line in a terminal UI). |
required |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of completion descriptor dictionaries contributed by |
List[Dict[str, Any]]
|
features. The exact shape of each entry is feature- and |
List[Dict[str, Any]]
|
application-defined; common keys include "replacement", |
List[Dict[str, Any]]
|
"start", "display", and "display_meta". |
Source code in core/python/agent_core/core.py
3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 | |
get_config_schema
get_config_schema()
Get flattened config schema from all registered plugins.
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List of config entry descriptors. Each element is a |
List[Dict[str, Any]]
|
dictionary that includes: |
List[Dict[str, Any]]
|
|
List[Dict[str, Any]]
|
|
List[Dict[str, Any]]
|
|
List[Dict[str, Any]]
|
Multiple plugins may contribute entries for the same |
List[Dict[str, Any]]
|
|
List[Dict[str, Any]]
|
element in the returned list. |
Source code in core/python/agent_core/core.py
2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 | |
get_plugins_for_config
get_plugins_for_config(config)
Return active plugin identifiers for the given config.
The result is derived from the same tag-based dependency resolution used internally by the core. It maps plugin kinds ("providers", "extensions", "features", "tools") to lists of active plugin identifiers for this config.
Source code in core/python/agent_core/core.py
1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 | |
get_session_actions
get_session_actions(config)
Return session-scoped extension and feature actions for the config.
Source code in core/python/agent_core/core.py
3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 | |
get_tool_schemas
get_tool_schemas(config)
Get the effective tool schemas for a config after feature policy.
Source code in core/python/agent_core/core.py
3848 3849 3850 3851 3852 3853 | |
get_ui_schema
get_ui_schema(config)
Get flattened UI schema for the effective config.
Plugins receive additional context computed from config:
tags: capability/environment tags produced by the provider and enabled plugins.models: model descriptors returned byget_modelshooks.
Each element is a dictionary describing a UI element contributed by a provider, extension, feature, or tool. The core treats the dictionaries as opaque and simply annotates and flattens them; applications decide how to render or interpret each entry.
Source code in core/python/agent_core/core.py
3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 | |
import_session
import_session(data, format='json')
Import a session from a serialized string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Serialized session string. |
required |
format
|
str
|
Import format. Only "json" is supported. |
'json'
|
Returns:
| Type | Description |
|---|---|
Session
|
A new Session reconstructed from the serialized data. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the format is not supported. |
Source code in core/python/agent_core/core.py
4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 | |
initialize_action_request
initialize_action_request(
native_messages, state, request_runtime, request_context
)
Apply request-time initialization to session-action inputs.
Session actions should see the same request-time state that normal
provider requests see, including feature/provider initialize_request
changes such as compiled top-level instructions.
Source code in core/python/agent_core/core.py
3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 | |
iter_tool_messages
iter_tool_messages(
tool_calls, config, *, cancellation=None, context=None
)
Yield a mixed stream of partial payloads and final core tool messages.
Tools stream via ToolPlugin.stream_tool. Partial display payloads are
yielded as-is when they contain a "part" key. Result dictionaries are
detected via the presence of a "success" key and transformed into final
core tool messages at the end of each tool call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_calls
|
List[Dict[str, Any]]
|
List of tool call dictionaries to execute. |
required |
config
|
Dict[str, Any]
|
Current resolved request configuration. |
required |
cancellation
|
Any | None
|
Optional cancellation token. |
None
|
context
|
Optional[Dict[str, Any]]
|
Optional context for tool execution. Layer 1 context (core, config, trigger_source) is enriched by this method if not already present. |
None
|
Source code in core/python/agent_core/core.py
4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 | |
join_sessions
join_sessions(prefix, suffix, config=None)
Join two sessions end-to-end, preserving native history when possible.
This helper concatenates the core messages from prefix and
suffix and, when both sessions contain provider-native history,
combines their native histories and rebuilds core messages from the
merged native sequence.
Note: arbitrary per-message Message.metadata is not preserved by
default across the native-history rebuild step. If metadata must
survive native rebuilds, it must be persisted into provider-native
messages via the _metadata key and reconstructed in
from_native_messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
Session
|
First session segment. |
required |
suffix
|
Session
|
Second session segment that should follow |
required |
config
|
Optional[Dict[str, Any]]
|
Optional configuration used when rebuilding from native history. When omitted, joins are performed in core-only mode. |
None
|
Returns:
| Type | Description |
|---|---|
Session
|
New Session instance representing the concatenation of |
Session
|
and |
Source code in core/python/agent_core/core.py
1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 | |
modify_message
modify_message(
session, index, content, config=None, *, context=None
)
Modify the content of an existing message (pure function).
Only system, user, and assistant messages are supported. The
message role and metadata remain unchanged. When provider-native
history is present and safely mappable via native_indices, the
corresponding native messages are updated. Otherwise, native history
is dropped and will be reconstructed on the next request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Current session. |
required |
index
|
int
|
Message index to modify (0-based; negative indices supported). |
required |
content
|
str
|
New message content. |
required |
config
|
Optional[Dict[str, Any]]
|
Optional configuration used to resolve provider and plugins when updating native history. |
None
|
Returns:
| Type | Description |
|---|---|
Session
|
New Session with the modified message (immutable update). |
Source code in core/python/agent_core/core.py
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 | |
patch_native_internal_metadata
patch_native_internal_metadata(
native_messages, indices, patch
)
Immutably merge patch into _metadata on selected native items.
Source code in core/python/agent_core/core.py
4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 | |
rebuild_native_history
rebuild_native_history(
session,
config=None,
*,
start=None,
end=None,
context=None
)
Rebuild provider-native history from the current core messages.
This helper converts the session's core messages to provider-native
form using the configured provider, extensions, and features, then
rebuilds the full core message sequence from that native history. When
start/end are provided, only the visible message slice
session.messages[start:end] is rebuilt back into native history
before the canonical full core transcript is reconstructed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Current session. |
required |
config
|
Optional[Dict[str, Any]]
|
Configuration used to resolve provider and plugins. |
None
|
start
|
Optional[int]
|
Optional inclusive visible-message start index for selective rebuild. Requires retained native history on the session. |
None
|
end
|
Optional[int]
|
Optional exclusive visible-message end index for selective rebuild. Requires retained native history on the session. |
None
|
Returns:
| Type | Description |
|---|---|
Session
|
New Session with native history rebuilt from core messages. |
Source code in core/python/agent_core/core.py
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 | |
register_feature
register_feature(plugin_class)
Register a feature plugin class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_class
|
type
|
Feature plugin class. |
required |
Source code in core/python/agent_core/core.py
635 636 637 638 639 640 641 642 643 | |
register_provider
register_provider(plugin_class, extensions=None)
Register provider plugin class with optional provider extensions.
Extensions are loaded by the provider wrapper (same language, hot path).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_class
|
type
|
Provider plugin class. |
required |
extensions
|
Optional[List[type]]
|
Optional list of provider extension classes to register with the provider. |
None
|
Source code in core/python/agent_core/core.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 | |
register_tool
register_tool(plugin_class)
Register a tool plugin class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plugin_class
|
type
|
Tool plugin class. |
required |
Source code in core/python/agent_core/core.py
645 646 647 648 649 650 651 652 653 | |
send_request
send_request(
session,
config,
*,
request_id=None,
cancellation=None,
context=None
)
Send request and return a new session with the response.
Runs provider call + finalize with features operating on provider-native data; converts provider-native finals to core at the end and appends them to the session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Current session. |
required |
config
|
Dict[str, Any]
|
Application-provided configuration for this request. |
required |
Returns:
| Type | Description |
|---|---|
Session
|
Tuple of (new_session, final_core_messages) where the new session includes the |
List[Dict[str, Any]]
|
appended final messages and retained provider-native history for this turn. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no provider is registered. |
Source code in core/python/agent_core/core.py
2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 | |
send_request_stream
send_request_stream(
session,
config,
*,
request_id=None,
cancellation=None,
context=None
)
Stream request and yield partial events, then the final session.
Uses provider streaming with optimized hot-path processing; features operate on the provider-native finals at finalize, then core converts once and appends to the session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Current session. |
required |
config
|
Dict[str, Any]
|
Application-provided configuration for this request. |
required |
Yields:
| Type | Description |
|---|---|
Dict[str, Any]
|
Event dictionaries: |
Dict[str, Any]
|
|
Dict[str, Any]
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no provider is registered. |
Source code in core/python/agent_core/core.py
2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 | |
send_request_stream_async
async
send_request_stream_async(
session,
config,
*,
request_id=None,
cancellation=None,
context=None
)
Async version of send_request_stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Current session. |
required |
config
|
Dict[str, Any]
|
Application-provided configuration for this request. |
required |
Yields:
| Type | Description |
|---|---|
AsyncIterator[Dict[str, Any]]
|
Event dictionaries analogous to send_request_stream, but from an async iterator. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no provider is registered. |
Source code in core/python/agent_core/core.py
2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 | |
slice_session
slice_session(
session,
config=None,
*,
start=None,
end=None,
remove_indices=None,
return_removed=False
)
Return a new session with messages sliced/removed.
Operations are expressed in core message indices but, when possible, provider-native history is adjusted consistently and preserved.
Source code in core/python/agent_core/core.py
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 | |
stream_tool_call
stream_tool_call(tool_call, config, *, context=None)
Stream partial results for a single tool call.
Uses the same tool resolution logic as :meth:execute_tool_calls but
invokes the optional :meth:ToolPlugin.stream_tool hook instead of the
synchronous execute/format path. If no tool provides streaming for the
given call, yields nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_call
|
Dict[str, Any]
|
Tool call dictionary to execute. |
required |
config
|
Dict[str, Any]
|
Current resolved request configuration. |
required |
context
|
Optional[Dict[str, Any]]
|
Optional context for tool execution. Layer 1 context (core, config, trigger_source) is enriched by this method if not already present. |
None
|
Source code in core/python/agent_core/core.py
4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 | |