Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions splunklib/ai/engines/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,10 +1354,7 @@ async def _tool_call(
"ToolException from LangChain should not be raised in tool.func"
)

# TODO: Should we change the splunklib.ai.tools.ToolResult.content to a str, instead of list[str]?
text_content = "\n".join(result.content)

artifact = ToolResult(text_content, result.structured_content)
artifact = ToolResult(result.content, result.structured_content)

if result.structured_content:
# For both local tools and remote tools (Splunk MCP Server App), the primary
Expand All @@ -1371,7 +1368,7 @@ async def _tool_call(
# this assumption may need to be revisited. For now, this approach is fine.
# Worst-case scenario is the same information is provided to the LLM twice.
return asdict(result), artifact # both content + structured_content
return text_content, artifact
return result.content, artifact

return StructuredTool(
name=_normalize_tool_name(tool.name, tool.type),
Expand Down
4 changes: 2 additions & 2 deletions splunklib/ai/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ToolException(Exception):

@dataclass(frozen=True)
class ToolResult:
content: list[str]
content: str
structured_content: dict[str, Any] | None


Expand Down Expand Up @@ -243,7 +243,7 @@ def _convert_tool_result(
text_contents.append(content.text)

return ToolResult(
content=text_contents, structured_content=result.structuredContent
content="\n".join(text_contents), structured_content=result.structuredContent
)


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/ai/test_tool_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


async def no_op() -> ToolResult:
return ToolResult(content=[], structured_content={})
return ToolResult(content="", structured_content={})


LOCAL_TOOL_1 = Tool(
Expand Down