Refactor: Establish Shared Core Architecture for Agentic RAG#201
Open
RajSidwadkar wants to merge 3 commits intokubeflow:mainfrom
Open
Refactor: Establish Shared Core Architecture for Agentic RAG#201RajSidwadkar wants to merge 3 commits intokubeflow:mainfrom
RajSidwadkar wants to merge 3 commits intokubeflow:mainfrom
Conversation
Signed-off-by: Raj <rajsidwadkar777@gmail.com>
…mory manager Signed-off-by: Raj <rajsidwadkar777@gmail.com>
Resolves kubeflow#200. This commit introduces the foundational Shared Core architecture for deterministic agent routing. - Creates core_agent/graph.py to act as the single source of truth for the LangGraph state machine. - Decouples AI routing logic from the FastAPI and WebSocket transport layers. - Adds comprehensive, fully-mocked PyTest suite in tests/test_graph.py to validate cyclic error correction and conditional edge transitions without network overhead. Signed-off-by: Raj <rajsidwadkar777@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Architectural Context & Motivation
This pull request addresses the structural limitations identified in Issue #200. As the application transitions from linear, non-deterministic tool-calling chains toward a robust Directed Acyclic Graph (DAG) for semantic routing, the existing codebase presented a risk of tight coupling.
Previously, agent logic was deeply integrated into the specific network transport layers (server/app.py for WebSockets and server-https/app.py for REST). Placing complex state-machine logic in these directories would violate DRY principles, introduce synchronization risks between the two APIs, and prevent isolated unit testing.
Implementation Details
This PR introduces the core_agent/ module, establishing a single source of truth for all conversational intelligence and retrieval routing.
Transport Decoupling: Both the ASGI WebSocket endpoints and the FastAPI HTTP endpoints have been refactored to act purely as network interfaces. They now import and invoke the compiled LangGraph state machine from core_agent.graph.
State Management (core_agent/graph.py): Scaffolded the foundational TypedDict state schema, integrating intent classification nodes and conditional edge definitions for deterministic routing.
Retrieval Isolation (core_agent/tools.py): Abstracted the Milvus partition targeting logic into independent callable tools, paving the way for the specialized index architecture (Docs, GitHub Issues, Platform Architecture).
Testing & Validation
To ensure high stability and rapid CI/CD execution, the routing logic has been entirely decoupled from external network latency.
Introduced tests/test_graph.py utilizing standard pytest and unittest.mock.
Transition Assertions: Verified all conditional edges (e.g., ensuring Debugging intents strictly route to the github_issues node).
Cyclic Recovery: Validated the failure-recovery loop by simulating hallucinated LLM responses, asserting that the state's error_count increments correctly and triggers a retry rather than failing silently or causing an infinite loop.
Note to Maintainers: This structural refactor serves as the foundational Phase 1 architecture for my GSoC proposal. It is designed to cleanly integrate alongside the
ContextWindowManageroptimizations introduced in PR #129.Resolves: #200