agentkernel 0.2.10__tar.gz → 0.2.11__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.
Files changed (95) hide show
  1. {agentkernel-0.2.10 → agentkernel-0.2.11}/PKG-INFO +174 -7
  2. {agentkernel-0.2.10 → agentkernel-0.2.11}/README.md +166 -0
  3. {agentkernel-0.2.10 → agentkernel-0.2.11}/pyproject.toml +10 -9
  4. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/api/a2a/a2a.py +1 -3
  5. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/api/handler.py +4 -15
  6. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/base.py +2 -2
  7. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/config.py +18 -9
  8. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/hooks.py +2 -6
  9. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/runtime.py +8 -11
  10. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/deployment/aws/aklambda.py +1 -3
  11. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/adk/adk.py +3 -11
  12. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/crewai/crewai.py +2 -6
  13. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/langgraph/langgraph.py +1 -3
  14. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/openai/openai.py +4 -12
  15. agentkernel-0.2.11/src/agentkernel/guardrail/bedrock.py +294 -0
  16. agentkernel-0.2.11/src/agentkernel/guardrail/guardrail.py +92 -0
  17. agentkernel-0.2.11/src/agentkernel/guardrail/openai.py +213 -0
  18. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/gmail/gmail_chat.py +7 -21
  19. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/slack/slack_chat.py +3 -9
  20. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/telegram/telegram_chat.py +1 -3
  21. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/whatsapp/whatsapp_chat.py +4 -12
  22. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/test/test.py +3 -9
  23. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/langfuse/langgraph.py +2 -6
  24. agentkernel-0.2.11/src/agentkernel/trace/openllmetry/__init__.py +0 -0
  25. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/__init__.py +0 -0
  26. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/adk.py +0 -0
  27. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/api/__init__.py +0 -0
  28. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/api/a2a/__init__.py +0 -0
  29. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/api/a2a/handler.py +0 -0
  30. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/api/http.py +0 -0
  31. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/api/mcp/__init__.py +0 -0
  32. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/api/mcp/akmcp.py +0 -0
  33. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/aws.py +0 -0
  34. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/cli/__init__.py +0 -0
  35. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/cli/cli.py +0 -0
  36. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/__init__.py +0 -0
  37. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/builder.py +0 -0
  38. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/model.py +0 -0
  39. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/module.py +0 -0
  40. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/service.py +0 -0
  41. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/session/__init__.py +0 -0
  42. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/session/base.py +0 -0
  43. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/session/dynamodb.py +0 -0
  44. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/session/in_memory.py +0 -0
  45. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/session/redis.py +0 -0
  46. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/session/serde.py +0 -0
  47. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/util/config_yaml_util.py +0 -0
  48. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/core/util/key_value_cache.py +0 -0
  49. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/crewai.py +0 -0
  50. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/deployment/__init__.py +0 -0
  51. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/deployment/aws/__init__.py +0 -0
  52. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/__init__.py +0 -0
  53. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/adk/__init__.py +0 -0
  54. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/crewai/__init__.py +0 -0
  55. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/langgraph/__init__.py +0 -0
  56. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/framework/openai/__init__.py +0 -0
  57. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/gmail.py +0 -0
  58. {agentkernel-0.2.10/src/agentkernel/trace/langfuse → agentkernel-0.2.11/src/agentkernel/guardrail}/__init__.py +0 -0
  59. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/instagram.py +0 -0
  60. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/__init__.py +0 -0
  61. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/gmail/README.md +0 -0
  62. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/gmail/__init__.py +0 -0
  63. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/instagram/README.md +0 -0
  64. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/instagram/__init__.py +0 -0
  65. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/instagram/instagram_chat.py +0 -0
  66. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/messenger/README.md +0 -0
  67. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/messenger/__init__.py +0 -0
  68. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/messenger/messenger_chat.py +0 -0
  69. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/slack/README.md +0 -0
  70. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/slack/__init__.py +0 -0
  71. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/telegram/README.md +0 -0
  72. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/telegram/__init__.py +0 -0
  73. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/whatsapp/README.md +0 -0
  74. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/integration/whatsapp/__init__.py +0 -0
  75. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/langgraph.py +0 -0
  76. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/mcp.py +0 -0
  77. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/messenger.py +0 -0
  78. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/openai.py +0 -0
  79. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/slack.py +0 -0
  80. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/telegram.py +0 -0
  81. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/test/__init__.py +0 -0
  82. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/__init__.py +0 -0
  83. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/base.py +0 -0
  84. {agentkernel-0.2.10/src/agentkernel/trace/openllmetry → agentkernel-0.2.11/src/agentkernel/trace/langfuse}/__init__.py +0 -0
  85. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/langfuse/adk.py +0 -0
  86. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/langfuse/crewai.py +0 -0
  87. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/langfuse/langfuse.py +0 -0
  88. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/langfuse/openai.py +0 -0
  89. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/openllmetry/adk.py +0 -0
  90. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/openllmetry/crewai.py +0 -0
  91. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/openllmetry/langgraph.py +0 -0
  92. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/openllmetry/openai.py +0 -0
  93. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/openllmetry/openllmetry.py +0 -0
  94. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/trace/trace.py +0 -0
  95. {agentkernel-0.2.10 → agentkernel-0.2.11}/src/agentkernel/whatsapp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: agentkernel
3
- Version: 0.2.10
3
+ Version: 0.2.11
4
4
  Summary: Agent Kernel - Unified AI Agents Runtime
5
5
  Author: Yaala Labs
6
6
  Author-email: Yaala Labs <agentkernel@yaalalabs.com>
@@ -28,14 +28,15 @@ Requires-Dist: google-api-python-client>=2.0.0 ; extra == 'gmail'
28
28
  Requires-Dist: httpx>=0.27.0 ; extra == 'instagram'
29
29
  Requires-Dist: langfuse>=3.9.2 ; extra == 'langfuse'
30
30
  Requires-Dist: nest-asyncio>=1.6.0 ; extra == 'langfuse'
31
- Requires-Dist: langgraph~=0.6.2 ; extra == 'langgraph'
32
- Requires-Dist: langchain~=0.3.27 ; extra == 'langgraph'
33
- Requires-Dist: langchain-community~=0.3.27 ; extra == 'langgraph'
34
- Requires-Dist: litellm~=1.74.3 ; extra == 'langgraph'
31
+ Requires-Dist: langgraph~=1.0.5 ; extra == 'langgraph'
32
+ Requires-Dist: langchain~=1.2.3 ; extra == 'langgraph'
33
+ Requires-Dist: langchain-community~=0.4.1 ; extra == 'langgraph'
34
+ Requires-Dist: litellm~=1.74.9 ; extra == 'langgraph'
35
35
  Requires-Dist: fastmcp>=2.12.4 ; extra == 'mcp'
36
36
  Requires-Dist: httpx>=0.27.0 ; extra == 'messenger'
37
- Requires-Dist: openai-agents>=0.6.3 ; extra == 'openai'
37
+ Requires-Dist: openai-agents>=0.6.5 ; extra == 'openai'
38
38
  Requires-Dist: openinference-instrumentation-openai-agents>=1.4.0 ; extra == 'openai'
39
+ Requires-Dist: openai-guardrails>=0.2.1 ; extra == 'openai'
39
40
  Requires-Dist: traceloop-sdk>=0.48.0 ; extra == 'openllmetry'
40
41
  Requires-Dist: redis>=7.1.0 ; extra == 'redis'
41
42
  Requires-Dist: slack-bolt==1.22.0 ; extra == 'slack'
@@ -52,7 +53,7 @@ Requires-Dist: datasets>=2.14.0 ; extra == 'test'
52
53
  Requires-Dist: pandas>=2.0.0 ; extra == 'test'
53
54
  Requires-Dist: litellm>=1.74.9 ; extra == 'test'
54
55
  Requires-Dist: httpx>=0.27.0 ; extra == 'whatsapp'
55
- Requires-Python: >=3.12
56
+ Requires-Python: >=3.12, <3.14
56
57
  Provides-Extra: a2a
57
58
  Provides-Extra: adk
58
59
  Provides-Extra: api
@@ -516,6 +517,138 @@ test:
516
517
  embedding_model: text-embedding-3-small
517
518
  ```
518
519
 
520
+ #### Guardrails Configuration
521
+
522
+ Configure input and output guardrails to validate agent requests and responses for safety and compliance.
523
+
524
+ - **Input Guardrails**
525
+ - **Enabled**
526
+ - **Field**: `guardrail.input.enabled`
527
+ - **Default**: `false`
528
+ - **Description**: Enable input validation guardrails
529
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__ENABLED`
530
+
531
+ - **Type**
532
+ - **Field**: `guardrail.input.type`
533
+ - **Default**: `openai`
534
+ - **Options**: `openai`, `bedrock`
535
+ - **Description**: Guardrail provider type
536
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__TYPE`
537
+
538
+ - **Config Path**
539
+ - **Field**: `guardrail.input.config_path`
540
+ - **Default**: `None`
541
+ - **Description**: Path to guardrail configuration JSON file (OpenAI only)
542
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__CONFIG_PATH`
543
+
544
+ - **Model**
545
+ - **Field**: `guardrail.input.model`
546
+ - **Default**: `gpt-4o-mini`
547
+ - **Description**: LLM model to use for guardrail validation (OpenAI only)
548
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__MODEL`
549
+
550
+ - **ID**
551
+ - **Field**: `guardrail.input.id`
552
+ - **Default**: `None`
553
+ - **Description**: AWS Bedrock guardrail ID (Bedrock only)
554
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__ID`
555
+
556
+ - **Version**
557
+ - **Field**: `guardrail.input.version`
558
+ - **Default**: `DRAFT`
559
+ - **Description**: AWS Bedrock guardrail version (Bedrock only)
560
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__VERSION`
561
+
562
+ - **Output Guardrails**
563
+ - **Enabled**
564
+ - **Field**: `guardrail.output.enabled`
565
+ - **Default**: `false`
566
+ - **Description**: Enable output validation guardrails
567
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__ENABLED`
568
+
569
+ - **Type**
570
+ - **Field**: `guardrail.output.type`
571
+ - **Default**: `openai`
572
+ - **Options**: `openai`, `bedrock`
573
+ - **Description**: Guardrail provider type
574
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__TYPE`
575
+
576
+ - **Config Path**
577
+ - **Field**: `guardrail.output.config_path`
578
+ - **Default**: `None`
579
+ - **Description**: Path to guardrail configuration JSON file (OpenAI only)
580
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__CONFIG_PATH`
581
+
582
+ - **Model**
583
+ - **Field**: `guardrail.output.model`
584
+ - **Default**: `gpt-4o-mini`
585
+ - **Description**: LLM model to use for guardrail validation (OpenAI only)
586
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__MODEL`
587
+
588
+ - **ID**
589
+ - **Field**: `guardrail.output.id`
590
+ - **Default**: `None`
591
+ - **Description**: AWS Bedrock guardrail ID (Bedrock only)
592
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__ID`
593
+
594
+ - **Version**
595
+ - **Field**: `guardrail.output.version`
596
+ - **Default**: `DRAFT`
597
+ - **Description**: AWS Bedrock guardrail version (Bedrock only)
598
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__VERSION`
599
+
600
+ **Guardrail Setup:**
601
+
602
+ To use OpenAI guardrails, install the openai-guardrails package:
603
+
604
+ ```bash
605
+ pip install agentkernel[openai]
606
+ ```
607
+
608
+ To use AWS Bedrock guardrails, install the AWS package:
609
+
610
+ ```bash
611
+ pip install agentkernel[aws]
612
+ ```
613
+
614
+ Create guardrail configuration:
615
+
616
+ **For OpenAI:** Create configuration files following the [OpenAI Guardrails format](https://guardrails.openai.com/).
617
+
618
+ **For Bedrock:** Create a guardrail in AWS Bedrock and note the guardrail ID and version.
619
+
620
+ Configure guardrails in your configuration:
621
+
622
+ **OpenAI Example:**
623
+ ```yaml
624
+ guardrail:
625
+ input:
626
+ enabled: true
627
+ type: openai
628
+ model: gpt-4o-mini
629
+ config_path: /path/to/guardrails_input.json
630
+ output:
631
+ enabled: true
632
+ type: openai
633
+ model: gpt-4o-mini
634
+ config_path: /path/to/guardrails_output.json
635
+ ```
636
+
637
+ **Bedrock Example:**
638
+ ```yaml
639
+ guardrail:
640
+ input:
641
+ enabled: true
642
+ type: bedrock
643
+ id: your-guardrail-id
644
+ version: "1" # or "DRAFT"
645
+ output:
646
+ enabled: true
647
+ type: bedrock
648
+ id: your-guardrail-id
649
+ version: "1"
650
+ ```
651
+
519
652
  #### Messaging Platform Integrations
520
653
 
521
654
  Configure integrations with messaging platforms.
@@ -617,6 +750,15 @@ export AK_TEST__MODE=fallback # Options: fuzzy, judge, fallback
617
750
  export AK_TEST__JUDGE__MODEL=gpt-4o-mini
618
751
  export AK_TEST__JUDGE__PROVIDER=openai
619
752
  export AK_TEST__JUDGE__EMBEDDING_MODEL=text-embedding-3-small
753
+ # Guardrails configuration
754
+ export AK_GUARDRAIL__INPUT__ENABLED=false
755
+ export AK_GUARDRAIL__INPUT__TYPE=openai
756
+ export AK_GUARDRAIL__INPUT__MODEL=gpt-4o-mini
757
+ export AK_GUARDRAIL__INPUT__CONFIG_PATH=/path/to/guardrails_input.json
758
+ export AK_GUARDRAIL__OUTPUT__ENABLED=false
759
+ export AK_GUARDRAIL__OUTPUT__TYPE=openai
760
+ export AK_GUARDRAIL__OUTPUT__MODEL=gpt-4o-mini
761
+ export AK_GUARDRAIL__OUTPUT__CONFIG_PATH=/path/to/guardrails_output.json
620
762
  # Messaging platforms (optional)
621
763
  export AK_SLACK__AGENT=my-agent
622
764
  export AK_WHATSAPP__AGENT=my-agent
@@ -686,6 +828,17 @@ test:
686
828
  model: gpt-4o-mini
687
829
  provider: openai
688
830
  embedding_model: text-embedding-3-small
831
+ guardrail:
832
+ input:
833
+ enabled: false
834
+ type: openai
835
+ model: gpt-4o-mini
836
+ config_path: /path/to/guardrails_input.json
837
+ output:
838
+ enabled: false
839
+ type: openai
840
+ model: gpt-4o-mini
841
+ config_path: /path/to/guardrails_output.json
689
842
  slack:
690
843
  agent: my-agent
691
844
  agent_acknowledgement: "Processing your request..."
@@ -748,6 +901,20 @@ gmail:
748
901
  "embedding_model": "text-embedding-3-small"
749
902
  }
750
903
  },
904
+ "guardrail": {
905
+ "input": {
906
+ "enabled": false,
907
+ "type": "openai",
908
+ "model": "gpt-4o-mini",
909
+ "config_path": "/path/to/guardrails_input.json"
910
+ },
911
+ "output": {
912
+ "enabled": false,
913
+ "type": "openai",
914
+ "model": "gpt-4o-mini",
915
+ "config_path": "/path/to/guardrails_output.json"
916
+ }
917
+ },
751
918
  "slack": {
752
919
  "agent": "my-agent",
753
920
  "agent_acknowledgement": "Processing your request..."
@@ -440,6 +440,138 @@ test:
440
440
  embedding_model: text-embedding-3-small
441
441
  ```
442
442
 
443
+ #### Guardrails Configuration
444
+
445
+ Configure input and output guardrails to validate agent requests and responses for safety and compliance.
446
+
447
+ - **Input Guardrails**
448
+ - **Enabled**
449
+ - **Field**: `guardrail.input.enabled`
450
+ - **Default**: `false`
451
+ - **Description**: Enable input validation guardrails
452
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__ENABLED`
453
+
454
+ - **Type**
455
+ - **Field**: `guardrail.input.type`
456
+ - **Default**: `openai`
457
+ - **Options**: `openai`, `bedrock`
458
+ - **Description**: Guardrail provider type
459
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__TYPE`
460
+
461
+ - **Config Path**
462
+ - **Field**: `guardrail.input.config_path`
463
+ - **Default**: `None`
464
+ - **Description**: Path to guardrail configuration JSON file (OpenAI only)
465
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__CONFIG_PATH`
466
+
467
+ - **Model**
468
+ - **Field**: `guardrail.input.model`
469
+ - **Default**: `gpt-4o-mini`
470
+ - **Description**: LLM model to use for guardrail validation (OpenAI only)
471
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__MODEL`
472
+
473
+ - **ID**
474
+ - **Field**: `guardrail.input.id`
475
+ - **Default**: `None`
476
+ - **Description**: AWS Bedrock guardrail ID (Bedrock only)
477
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__ID`
478
+
479
+ - **Version**
480
+ - **Field**: `guardrail.input.version`
481
+ - **Default**: `DRAFT`
482
+ - **Description**: AWS Bedrock guardrail version (Bedrock only)
483
+ - **Environment Variable**: `AK_GUARDRAIL__INPUT__VERSION`
484
+
485
+ - **Output Guardrails**
486
+ - **Enabled**
487
+ - **Field**: `guardrail.output.enabled`
488
+ - **Default**: `false`
489
+ - **Description**: Enable output validation guardrails
490
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__ENABLED`
491
+
492
+ - **Type**
493
+ - **Field**: `guardrail.output.type`
494
+ - **Default**: `openai`
495
+ - **Options**: `openai`, `bedrock`
496
+ - **Description**: Guardrail provider type
497
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__TYPE`
498
+
499
+ - **Config Path**
500
+ - **Field**: `guardrail.output.config_path`
501
+ - **Default**: `None`
502
+ - **Description**: Path to guardrail configuration JSON file (OpenAI only)
503
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__CONFIG_PATH`
504
+
505
+ - **Model**
506
+ - **Field**: `guardrail.output.model`
507
+ - **Default**: `gpt-4o-mini`
508
+ - **Description**: LLM model to use for guardrail validation (OpenAI only)
509
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__MODEL`
510
+
511
+ - **ID**
512
+ - **Field**: `guardrail.output.id`
513
+ - **Default**: `None`
514
+ - **Description**: AWS Bedrock guardrail ID (Bedrock only)
515
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__ID`
516
+
517
+ - **Version**
518
+ - **Field**: `guardrail.output.version`
519
+ - **Default**: `DRAFT`
520
+ - **Description**: AWS Bedrock guardrail version (Bedrock only)
521
+ - **Environment Variable**: `AK_GUARDRAIL__OUTPUT__VERSION`
522
+
523
+ **Guardrail Setup:**
524
+
525
+ To use OpenAI guardrails, install the openai-guardrails package:
526
+
527
+ ```bash
528
+ pip install agentkernel[openai]
529
+ ```
530
+
531
+ To use AWS Bedrock guardrails, install the AWS package:
532
+
533
+ ```bash
534
+ pip install agentkernel[aws]
535
+ ```
536
+
537
+ Create guardrail configuration:
538
+
539
+ **For OpenAI:** Create configuration files following the [OpenAI Guardrails format](https://guardrails.openai.com/).
540
+
541
+ **For Bedrock:** Create a guardrail in AWS Bedrock and note the guardrail ID and version.
542
+
543
+ Configure guardrails in your configuration:
544
+
545
+ **OpenAI Example:**
546
+ ```yaml
547
+ guardrail:
548
+ input:
549
+ enabled: true
550
+ type: openai
551
+ model: gpt-4o-mini
552
+ config_path: /path/to/guardrails_input.json
553
+ output:
554
+ enabled: true
555
+ type: openai
556
+ model: gpt-4o-mini
557
+ config_path: /path/to/guardrails_output.json
558
+ ```
559
+
560
+ **Bedrock Example:**
561
+ ```yaml
562
+ guardrail:
563
+ input:
564
+ enabled: true
565
+ type: bedrock
566
+ id: your-guardrail-id
567
+ version: "1" # or "DRAFT"
568
+ output:
569
+ enabled: true
570
+ type: bedrock
571
+ id: your-guardrail-id
572
+ version: "1"
573
+ ```
574
+
443
575
  #### Messaging Platform Integrations
444
576
 
445
577
  Configure integrations with messaging platforms.
@@ -541,6 +673,15 @@ export AK_TEST__MODE=fallback # Options: fuzzy, judge, fallback
541
673
  export AK_TEST__JUDGE__MODEL=gpt-4o-mini
542
674
  export AK_TEST__JUDGE__PROVIDER=openai
543
675
  export AK_TEST__JUDGE__EMBEDDING_MODEL=text-embedding-3-small
676
+ # Guardrails configuration
677
+ export AK_GUARDRAIL__INPUT__ENABLED=false
678
+ export AK_GUARDRAIL__INPUT__TYPE=openai
679
+ export AK_GUARDRAIL__INPUT__MODEL=gpt-4o-mini
680
+ export AK_GUARDRAIL__INPUT__CONFIG_PATH=/path/to/guardrails_input.json
681
+ export AK_GUARDRAIL__OUTPUT__ENABLED=false
682
+ export AK_GUARDRAIL__OUTPUT__TYPE=openai
683
+ export AK_GUARDRAIL__OUTPUT__MODEL=gpt-4o-mini
684
+ export AK_GUARDRAIL__OUTPUT__CONFIG_PATH=/path/to/guardrails_output.json
544
685
  # Messaging platforms (optional)
545
686
  export AK_SLACK__AGENT=my-agent
546
687
  export AK_WHATSAPP__AGENT=my-agent
@@ -610,6 +751,17 @@ test:
610
751
  model: gpt-4o-mini
611
752
  provider: openai
612
753
  embedding_model: text-embedding-3-small
754
+ guardrail:
755
+ input:
756
+ enabled: false
757
+ type: openai
758
+ model: gpt-4o-mini
759
+ config_path: /path/to/guardrails_input.json
760
+ output:
761
+ enabled: false
762
+ type: openai
763
+ model: gpt-4o-mini
764
+ config_path: /path/to/guardrails_output.json
613
765
  slack:
614
766
  agent: my-agent
615
767
  agent_acknowledgement: "Processing your request..."
@@ -672,6 +824,20 @@ gmail:
672
824
  "embedding_model": "text-embedding-3-small"
673
825
  }
674
826
  },
827
+ "guardrail": {
828
+ "input": {
829
+ "enabled": false,
830
+ "type": "openai",
831
+ "model": "gpt-4o-mini",
832
+ "config_path": "/path/to/guardrails_input.json"
833
+ },
834
+ "output": {
835
+ "enabled": false,
836
+ "type": "openai",
837
+ "model": "gpt-4o-mini",
838
+ "config_path": "/path/to/guardrails_output.json"
839
+ }
840
+ },
675
841
  "slack": {
676
842
  "agent": "my-agent",
677
843
  "agent_acknowledgement": "Processing your request..."
@@ -4,10 +4,10 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "agentkernel"
7
- version = "0.2.10"
7
+ version = "0.2.11"
8
8
  description = "Agent Kernel - Unified AI Agents Runtime"
9
9
  readme = "README.md"
10
- requires-python = ">=3.12"
10
+ requires-python = ">=3.12,<3.14"
11
11
  license = { text = "MIT" }
12
12
  authors = [
13
13
  { name = "Yaala Labs", email = "agentkernel@yaalalabs.com" }
@@ -34,10 +34,10 @@ crewai = [
34
34
  "openinference-instrumentation-litellm>=0.1.28",
35
35
  ]
36
36
  langgraph = [
37
- "langgraph~=0.6.2",
38
- "langchain~=0.3.27",
39
- "langchain_community~=0.3.27",
40
- "litellm~=1.74.3"
37
+ "langgraph~=1.0.5",
38
+ "langchain~=1.2.3",
39
+ "langchain_community~=0.4.1",
40
+ "litellm~=1.74.9"
41
41
  ]
42
42
  cli = [
43
43
 
@@ -49,8 +49,9 @@ redis = [
49
49
  "redis>=7.1.0",
50
50
  ]
51
51
  openai = [
52
- "openai-agents>=0.6.3",
52
+ "openai-agents>=0.6.5",
53
53
  "openinference-instrumentation-openai-agents>=1.4.0",
54
+ "openai-guardrails>=0.2.1",
54
55
  ]
55
56
  adk = [
56
57
  "google-adk>=1.14.1",
@@ -116,7 +117,7 @@ package = true
116
117
 
117
118
  [tool.isort]
118
119
  profile = "black"
119
- line_length = 120
120
+ line_length = 150
120
121
 
121
122
  [tool.mypy]
122
123
  python_version = "3.12"
@@ -126,7 +127,7 @@ disallow_untyped_defs = true
126
127
  disallow_incomplete_defs = true
127
128
 
128
129
  [tool.black]
129
- line-length = 120
130
+ line-length = 150
130
131
  target-version = ["py312"]
131
132
 
132
133
  [tool.pytest.ini_options]
@@ -46,9 +46,7 @@ class A2A:
46
46
  raise ValueError("RequestContext must have a message")
47
47
  try:
48
48
  response = await self._execute_agent(context.context_id, context.get_user_input())
49
- await event_queue.enqueue_event(
50
- new_agent_text_message(str(response), context.context_id, context.task_id)
51
- )
49
+ await event_queue.enqueue_event(new_agent_text_message(str(response), context.context_id, context.task_id))
52
50
  except Exception as e:
53
51
  error = "Sorry, Agent Kernel encountered an error while processing your request"
54
52
  self.log.error(traceback.format_exc())
@@ -140,10 +140,7 @@ class AgentRESTRequestHandler(RESTRequestHandler):
140
140
  if req.images:
141
141
  for image in req.images:
142
142
  self._log.debug(f"Adding image: {image.name}")
143
- if (
144
- not image.image_data.startswith(("http://", "https://", "data:", "s3://"))
145
- and not image.mime_type
146
- ):
143
+ if not image.image_data.startswith(("http://", "https://", "data:", "s3://")) and not image.mime_type:
147
144
  raise ValueError("mime_type is missing for image input, either in the base64 or explicitly")
148
145
  requests.append(
149
146
  AgentRequestImage(
@@ -170,9 +167,7 @@ class AgentRESTRequestHandler(RESTRequestHandler):
170
167
 
171
168
  return {
172
169
  "result": (
173
- str(result)
174
- if isinstance(result, (AgentReplyText, AgentReplyImage))
175
- else "Non textual result received"
170
+ str(result) if isinstance(result, (AgentReplyText, AgentReplyImage)) else "Non textual result received"
176
171
  ), # sending image is not supported at the moment
177
172
  "session_id": service.get_response_session_id(req.session_id),
178
173
  }
@@ -185,9 +180,7 @@ class AgentRESTRequestHandler(RESTRequestHandler):
185
180
  status_code=HTTPStatus.BAD_REQUEST,
186
181
  detail={
187
182
  "error": str(e),
188
- "session_id": (
189
- service.get_response_session_id(req.session_id) if service is not None else req.session_id
190
- ),
183
+ "session_id": (service.get_response_session_id(req.session_id) if service is not None else req.session_id),
191
184
  },
192
185
  )
193
186
  except Exception as e:
@@ -295,11 +288,7 @@ class AgentRESTRequestHandler(RESTRequestHandler):
295
288
  self._log.debug(f"Result: {result}")
296
289
 
297
290
  return {
298
- "result": (
299
- str(result)
300
- if isinstance(result, (AgentReplyText, AgentReplyImage))
301
- else "Non textual result received"
302
- ),
291
+ "result": (str(result) if isinstance(result, (AgentReplyText, AgentReplyImage)) else "Non textual result received"),
303
292
  "session_id": service.get_response_session_id(session_id),
304
293
  }
305
294
 
@@ -171,13 +171,13 @@ class Runner(ABC):
171
171
  @abstractmethod
172
172
  async def run(self, agent: Any, session: Session, requests: list[AgentRequest]) -> AgentReply:
173
173
  """
174
- Runs the agent with the provided multi modal inputs.
174
+ Runs the agent with the provided multi-modal inputs.
175
175
  :param agent: The agent to run.
176
176
  :param session: The session to use for the agent.
177
177
  :param requests: The list of requests to provide to the agent.
178
178
  :return: The result of the agent's execution.
179
179
  """
180
- pass
180
+ raise NotImplementedError
181
181
 
182
182
 
183
183
  class Agent(ABC):
@@ -137,6 +137,20 @@ class _TestConfig(BaseModel):
137
137
  judge: _JudgeConfig = Field(description="Judge configuration", default_factory=_JudgeConfig)
138
138
 
139
139
 
140
+ class _GuardrailParamConfig(BaseModel):
141
+ enabled: bool = Field(default=False, description="Enable Guardrail")
142
+ type: str = Field(default="openai", pattern="^(openai|bedrock)$")
143
+ config_path: Optional[str] = Field(default=None, description="Path to guardrail configuration file (OpenAI only)")
144
+ model: Optional[str] = Field(default="gpt-4o-mini", description="LLM model name to use for guardrail (OpenAI only)")
145
+ id: Optional[str] = Field(default=None, description="AWS Bedrock guardrail ID (Bedrock only)")
146
+ version: Optional[str] = Field(default="DRAFT", description="AWS Bedrock guardrail version (Bedrock only)")
147
+
148
+
149
+ class _GuardrailConfig(BaseModel):
150
+ input: _GuardrailParamConfig = Field(description="Input Guardrail configuration", default_factory=_GuardrailParamConfig)
151
+ output: _GuardrailParamConfig = Field(description="Output Guardrail configuration", default_factory=_GuardrailParamConfig)
152
+
153
+
140
154
  class AKConfig(YamlBaseSettingsModified):
141
155
  debug: bool = Field(default=False, description="Enable debug mode")
142
156
  session: _SessionStoreConfig = Field(
@@ -151,19 +165,14 @@ class AKConfig(YamlBaseSettingsModified):
151
165
  )
152
166
  slack: _SlackConfig = Field(description="Slack related configurations", default_factory=_SlackConfig)
153
167
  whatsapp: _WhatsAppConfig = Field(description="WhatsApp related configurations", default_factory=_WhatsAppConfig)
154
- messenger: _MessengerConfig = Field(
155
- description="Facebook Messenger related configurations", default_factory=_MessengerConfig
156
- )
157
- instagram: _InstagramConfig = Field(
158
- description="Instagram Business API related configurations", default_factory=_InstagramConfig
159
- )
160
- telegram: _TelegramConfig = Field(
161
- description="Telegram Bot related configurations", default_factory=_TelegramConfig
162
- )
168
+ messenger: _MessengerConfig = Field(description="Facebook Messenger related configurations", default_factory=_MessengerConfig)
169
+ instagram: _InstagramConfig = Field(description="Instagram Business API related configurations", default_factory=_InstagramConfig)
170
+ telegram: _TelegramConfig = Field(description="Telegram Bot related configurations", default_factory=_TelegramConfig)
163
171
  gmail: _GmailConfig = Field(description="Gmail related configurations", default_factory=_GmailConfig)
164
172
 
165
173
  trace: _TraceConfig = Field(description="Tracing related configurations", default_factory=_TraceConfig)
166
174
  test: _TestConfig = Field(description="Test related configurations", default_factory=_TestConfig)
175
+ guardrail: _GuardrailConfig = Field(description="Guardrail related configurations", default_factory=_GuardrailConfig)
167
176
  library_version: str = Field(default=_get_ak_version(), description="Library version")
168
177
 
169
178
  @classmethod
@@ -18,9 +18,7 @@ Currently, they will get only called for the initial execution of an agent when
18
18
 
19
19
  class PreHook(ABC):
20
20
  @abstractmethod
21
- async def on_run(
22
- self, session: "Session", agent: "Agent", requests: list[AgentRequest]
23
- ) -> list[AgentRequest] | AgentReply:
21
+ async def on_run(self, session: "Session", agent: "Agent", requests: list[AgentRequest]) -> list[AgentRequest] | AgentReply:
24
22
  """
25
23
  Hook method called before an agent starts executing a prompt. These hooks can modify the prompt or halt execution.
26
24
  Some use cases:
@@ -49,9 +47,7 @@ class PreHook(ABC):
49
47
 
50
48
  class PostHook(ABC):
51
49
  @abstractmethod
52
- async def on_run(
53
- self, session: "Session", requests: list[AgentRequest], agent: "Agent", agent_reply: AgentReply
54
- ) -> AgentReply:
50
+ async def on_run(self, session: "Session", requests: list[AgentRequest], agent: "Agent", agent_reply: AgentReply) -> AgentReply:
55
51
  """
56
52
  Hook method called after an agent finishes executing a prompt. These hooks can modify the agent's reply. Some use cases:
57
53
  - Moderation of agent replies. e.g. output guardrails
@@ -9,6 +9,7 @@ from typing import Optional
9
9
  from singleton_type import Singleton
10
10
 
11
11
  from ..core.util.key_value_cache import KeyValueCache
12
+ from ..guardrail.guardrail import InputGuardrailFactory, OutputGuardrailFactory
12
13
  from .base import Agent, Session
13
14
  from .builder import SessionStoreBuilder
14
15
  from .model import (
@@ -31,6 +32,8 @@ class Runtime:
31
32
 
32
33
  _current: Optional[Runtime] = None
33
34
  _lock: RLock = RLock()
35
+ _system_pre_hooks: list = [InputGuardrailFactory.get()]
36
+ _system_post_hooks: list = [OutputGuardrailFactory.get()]
34
37
 
35
38
  def __init__(self, sessions: SessionStore):
36
39
  """
@@ -134,13 +137,11 @@ class Runtime:
134
137
  """
135
138
  self._log.debug(f"Executing pre hooks with agent '{agent.name}' and requests: {requests}")
136
139
 
137
- pre_hooks = agent.pre_hooks
140
+ pre_hooks = agent.pre_hooks + self._system_pre_hooks # system pre-hooks are always executed last
138
141
  for hook in pre_hooks:
139
142
  reply = await hook.on_run(session, agent, requests)
140
143
  if isinstance(reply, (AgentReplyText, AgentReplyImage)):
141
- self._log.debug(
142
- f"PreHook halted execution for agent '{agent.name}' by hook '{hook.name()}' with reply: {reply}"
143
- )
144
+ self._log.debug(f"PreHook halted execution for agent '{agent.name}' by hook '{hook.name()}' with reply: {reply}")
144
145
  return reply
145
146
 
146
147
  # Validation to ensure the correct type is returned from the hooks. This is important to avoid runtime errors.
@@ -151,22 +152,18 @@ class Runtime:
151
152
  f"PreHook '{hook.name()}' returned an invalid type in the requests list. Expected AgentRequest, got {type(item)}"
152
153
  )
153
154
  else:
154
- raise TypeError(
155
- f"PreHook '{hook.name()}' returned an invalid type. Expected list[AgentRequest], got {type(reply)}"
156
- )
155
+ raise TypeError(f"PreHook '{hook.name()}' returned an invalid type. Expected list[AgentRequest], got {type(reply)}")
157
156
  requests = reply
158
157
 
159
158
  self._log.debug(f"Running agent '{agent.name}' with requests: {requests}")
160
159
 
161
160
  reply = await agent.runner.run(agent, session, requests)
162
161
 
163
- post_hooks = agent.post_hooks
162
+ post_hooks = self._system_post_hooks + agent.post_hooks # system post-hooks are always executed first
164
163
  for hook in post_hooks:
165
164
  reply = await hook.on_run(session, requests, agent, reply)
166
165
  if not isinstance(reply, (AgentReplyText, AgentReplyImage)):
167
- raise TypeError(
168
- f"PostHook '{hook.name()}' returned an invalid type. Expected AgentReply, got {type(reply)}"
169
- )
166
+ raise TypeError(f"PostHook '{hook.name()}' returned an invalid type. Expected AgentReply, got {type(reply)}")
170
167
  self._log.debug(f"PostHook executed for agent '{agent.name}' by hook '{hook.name()}' reply: {reply}")
171
168
  return reply
172
169