Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concept of self-hosted agent #10624

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ankitbko
Copy link
Member

@ankitbko ankitbko commented Feb 20, 2025

Motivation and Context

In the agentic world, different agents are created and maintained by different teams in an organization. Each team has their own way of creating agents and hosting them which are independent of each other. To utilize these agents when creating a multi-agent application, semantic kernel will need to integrate with agents which lies outside the semantic kernel application. For semantic kernel, these agents are black box services that have their own implementation of "intelligence" but could still use the plugins registered in kernel as needed. AgentGroupChat should be able to orchestrate between these agents as usual.

Description

Although there could be multiple ways to implement such concept, this PR takes the approach of deriving from ChatCompletionClientBase and taking inspiration from OpenAIChatCompletionBase to implement SelfHostedChatCompletion which makes a REST request to externally hosted agents. Instances of SelfHostedChatCompletion are registered as service in kernel

kernel.add_service(
    SelfHostedChatCompletion(
        url=os.getenv("REVIEWER_AGENT_URL") or "", ai_model_id=REVIEWER_NAME, service_id=REVIEWER_NAME
    )
)

ChatCompletionAgent is used to create agents and the appropriate service is referenced using service_id.

agent_reviewer = ChatCompletionAgent(
    service_id="artdirector",
    kernel=kernel,
    name=REVIEWER_NAME,
    arguments=KernelArguments(settings=PromptExecutionSettings(service_id=REVIEWER_NAME)),
)

The agents themselves are implemented in a fastapi server under agents folder. AgentGroupChat is used to orchestrate between the agents.

Contribution Checklist

@ankitbko ankitbko requested a review from a team as a code owner February 20, 2025 16:07
from semantic_kernel.connectors.ai.prompt_execution_settings import PromptExecutionSettings


class SelfHostedChatCompletion(ChatCompletionClientBase):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I get the point of this extra implementation, the OpenAIChatCompletion can take any URL and as long as the response matches it should just work and it seems the API you create does just that?

And in addition we have support for other local models, through Ollama, ONNX and Hugging Face...

Copy link
Member Author

@ankitbko ankitbko Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our customer is evaluating SK as orchestration platform to build multi-agent system where different agents are developed and deployed by different teams. These agents could have their own contract and authN mechanism. In other words, agents are "microservices".

Eventually these agents' contract will converge to a unified standard within their org. At the bare minimum we foresee the contract to include message history and tools support, rest of all AOAI Chat Completion parameters are not needed as they are internal implementation of an agent. Just for simplicity for demonstrating this concept, we assume the agents' contract follows OpenAI Chat Completion, but it does not have to be the case.

The key requirement is that agent implementation (whether local models or AOAI) is external to SK app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants