feat: Add a custom header to the SDK for chatting with the agent. (#12430)

### What problem does this PR solve?

As title.

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

Co-authored-by: Liu An <asiro@qq.com>
This commit is contained in:
zhanglei
2026-02-03 11:01:18 +08:00
committed by GitHub
parent aa8d0a36f1
commit 7cbe8b5b53
4 changed files with 20 additions and 7 deletions

View File

@ -76,6 +76,8 @@ class AgentParam(LLMParam, ToolParamBase):
self.mcp = []
self.max_rounds = 5
self.description = ""
self.custom_header = {}
class Agent(LLM, ToolBase):
@ -105,7 +107,8 @@ class Agent(LLM, ToolBase):
for mcp in self._param.mcp:
_, mcp_server = MCPServerService.get_by_id(mcp["mcp_id"])
tool_call_session = MCPToolCallSession(mcp_server, mcp_server.variables)
custom_header = self._param.custom_header
tool_call_session = MCPToolCallSession(mcp_server, mcp_server.variables, custom_header)
for tnm, meta in mcp["tools"].items():
self.tool_meta.append(mcp_tool_metadata_to_openai_tool(meta))
self.tools[tnm] = tool_call_session