Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ed1dbd1
Add ALTK Agent with tool validation and comprehensive tests
Nov 13, 2025
dfce983
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 13, 2025
d732664
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 13, 2025
7ac153c
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 13, 2025
e4a8a10
minor fix to execute_tool that was left out.
Nov 13, 2025
017f60f
Fixes following coderabbitai comments.
Nov 13, 2025
e693f74
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 13, 2025
7df715b
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 13, 2025
bf861ab
Merge branch 'main' into pr/10587
edwinjosechittilappilly Nov 13, 2025
87d0d27
Update component_index.json
edwinjosechittilappilly Nov 13, 2025
9d06c37
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 13, 2025
f0c5799
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 13, 2025
6354622
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 13, 2025
7b778ce
Add custom message to dict conversion in ValidatedTool
edwinjosechittilappilly Nov 13, 2025
f6c20c2
Merge branch 'fix_base_message_conversion' into pr/10587
edwinjosechittilappilly Nov 13, 2025
b2fdccf
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 13, 2025
627eef1
Merge branch 'main' into altk_agent_clean_pr
edwinjosechittilappilly Nov 13, 2025
7699f11
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 13, 2025
d199aca
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 13, 2025
483af42
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 13, 2025
077ebf6
Merge branch 'main' into pr/10587
edwinjosechittilappilly Nov 13, 2025
8064072
Add Notion integration components to index
edwinjosechittilappilly Nov 13, 2025
15ebdd0
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 13, 2025
8809833
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 13, 2025
6dd0501
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 13, 2025
8e92f44
Merge branch 'main' into altk_agent_clean_pr
edwinjosechittilappilly Nov 13, 2025
da77b5d
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 13, 2025
d6368cf
Merge branch 'main' into altk_agent_clean_pr
edwinjosechittilappilly Nov 13, 2025
d33b9e2
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 13, 2025
56e8ab2
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 13, 2025
86f0e02
[autofix.ci] apply automated fixes (attempt 3/3)
autofix-ci[bot] Nov 13, 2025
432fe57
Merge branch 'main' into altk_agent_clean_pr
edwinjosechittilappilly Nov 14, 2025
5595c18
[autofix.ci] apply automated fixes
autofix-ci[bot] Nov 14, 2025
272b295
[autofix.ci] apply automated fixes (attempt 2/3)
autofix-ci[bot] Nov 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lfx/src/lfx/base/agents/altk_base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
on user-facing configuration and small customizations.
"""

from __future__ import annotations

import uuid
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, cast

from altk.core.llm import get_llm
from langchain.agents import AgentExecutor, BaseMultiActionAgent, BaseSingleActionAgent
from langchain_anthropic.chat_models import ChatAnthropic
from langchain_core.language_models.chat_models import BaseChatModel
from langchain_core.messages import BaseMessage, HumanMessage
from langchain_core.runnables import Runnable, RunnableBinding
from langchain_core.tools import BaseTool
from langchain_openai.chat_models.base import ChatOpenAI
from pydantic import Field

from lfx.base.agents.callback import AgentAsyncHandler
from lfx.base.agents.events import ExceptionWithMessageError, process_agent_events
from lfx.base.agents.utils import data_to_messages, get_chat_output_sender_name
from lfx.components.agents import AgentComponent
from lfx.log.logger import logger
from lfx.memory import delete_message
from lfx.schema.content_block import ContentBlock
from lfx.schema.data import Data
from pydantic import Field

Check failure on line 30 in src/lfx/src/lfx/base/agents/altk_base_agent.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (I001)

src/lfx/src/lfx/base/agents/altk_base_agent.py:7:1: I001 Import block is un-sorted or un-formatted

if TYPE_CHECKING:
from collections.abc import Sequence
Expand Down
13 changes: 11 additions & 2 deletions src/lfx/src/lfx/base/agents/altk_tool_wrappers.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import ast
import json
import uuid
from typing import Any

from altk.core.toolkit import AgentPhase, ComponentConfig
from altk.post_tool.code_generation.code_generation import (
CodeGenerationComponent,
CodeGenerationComponentConfig,
)
from altk.post_tool.core.toolkit import CodeGenerationRunInput
from altk.pre_tool.core import SPARCExecutionMode, SPARCReflectionRunInput, Track
from altk.pre_tool.sparc import SPARCReflectionComponent
from langchain_core.messages import BaseMessage
from langchain_core.messages.base import message_to_dict
from langchain_core.tools import BaseTool
from pydantic import Field

from lfx.base.agents.altk_base_agent import ALTKBaseTool, BaseToolWrapper
from lfx.log.logger import logger
from lfx.schema.data import Data
from pydantic import Field

Check failure on line 21 in src/lfx/src/lfx/base/agents/altk_tool_wrappers.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (I001)

src/lfx/src/lfx/base/agents/altk_tool_wrappers.py:1:1: I001 Import block is un-sorted or un-formatted

# Maximum wrapper nesting depth to prevent infinite loops
_MAX_WRAPPER_DEPTH = 10
Expand Down Expand Up @@ -141,6 +141,15 @@
)
return self._validate_and_run(*args, **kwargs)

@staticmethod
def _custom_message_to_dict(message: BaseMessage) -> dict:
"""Convert a BaseMessage to a dictionary."""
if isinstance(message,BaseMessage):
return message_to_dict(message)
msg = f"Invalid message type: {type(message)}"
logger.error(msg,exc_info=True)
raise ValueError(msg) from None

def _validate_and_run(self, *args, **kwargs) -> str:
"""Validate the tool call using SPARC and execute if valid."""
# Check if validation should be bypassed
Expand All @@ -163,7 +172,7 @@
and isinstance(self.conversation_context[0], BaseMessage)
):
logger.debug("Converting BaseMessages to list of dictionaries for conversation context of SPARC")
self.conversation_context = [message_to_dict(msg) for msg in self.conversation_context]
self.conversation_context = [self._custom_message_to_dict(msg) for msg in self.conversation_context]

logger.debug(
f"Converted conversation context for SPARC for tool call:\n"
Expand Down
Loading