Skip to content

Epic 4.5: Extract LLMFactory from OpenSpace#34

Merged
Deepfreezechill merged 2 commits into
mainfrom
epic/4.5-llm-factory
Apr 3, 2026
Merged

Epic 4.5: Extract LLMFactory from OpenSpace#34
Deepfreezechill merged 2 commits into
mainfrom
epic/4.5-llm-factory

Conversation

@Deepfreezechill

Copy link
Copy Markdown
Owner

Summary

Extracts LLM client creation from OpenSpace.initialize() into LLMFactory.

What moved

  • Main LLMClient construction (5 config params + kwargs) → LLMFactory.create_main()
  • Tool retrieval LLM construction (model + shared credentials) → LLMFactory.create_tool_retrieval()

Impact

  • llm_factory.py: 68 lines (new)
  • tool_layer.py: -12 net lines (18 removed, 6 added)
  • 16 tests in test_llm_factory.py
  • 1,356 existing tests pass

Review: 5 agents, all APPROVE

  • /8eyes: impl, test-writer, security
  • /collab: GPT-5.4, Opus 4.6

Brian Krafft and others added 2 commits April 3, 2026 13:06
New module: openspace/llm_factory.py (66 lines)
- LLMFactory class: centralized LLM client creation from config
- create_main(): primary LLM client with full config params
- create_tool_retrieval(): optional tool retrieval LLM (shares credentials)

tool_layer.py: replaced 18 lines of inline LLM construction
with 6 lines delegating to LLMFactory (-12 net lines)

Tests: 12 tests in test_llm_factory.py
- Init state and config storage
- create_main: full config passthrough, defaults, idempotency
- create_tool_retrieval: enabled/disabled, config passthrough, kwargs inheritance
- OpenSpace backward compatibility

All 1,356 existing tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add docstring note on intentional param asymmetry in create_tool_retrieval()
- Add empty-string model test (M1: treats '' same as None)
- Add create_tool_retrieval twice test (M2: idempotency)
- Add constructor exception test (C2: propagates, client stays None)
- Fix fragile call_args unpacking (use .kwargs)

Tests: 12 → 16

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Deepfreezechill Deepfreezechill merged commit 5537f7f into main Apr 3, 2026
0 of 5 checks passed
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown

🔒 Phase Gate Enforcement — 🚫 FAIL

Check Result Detail
Issue linkage No linked issues found. PR must contain "Closes #N", "Fixes #N", or "Resolves #N".

Verdict: FAIL
Timestamp: 2026-04-03T20:11:34.759Z
Run: View workflow run


How to fix: Ensure all prerequisite phases are complete, or add emergency:bypass label with a ## Bypass Reason section in the PR body.

Deepfreezechill pushed a commit that referenced this pull request Apr 3, 2026
Restructure initialize() from 190-line monolith into clean orchestration:
- initialize(): 70-line high-level flow with numbered steps
- _load_grounding_config(): config loading, backend scope resolution
- _setup_skill_engine(): skill registry, store, analyzer, evolver

Cleanup:
- Remove dead imports (asyncio, uuid — now in ExecutionEngine)
- Remove stale extraction comments (4.1/4.3 notes)
- Update from_container docstring (remove Phase 4 TODO — it's done)

Public API unchanged. All 1,356 tests pass.

P4 tool_layer.py decomposition summary (788 → 477 lines, -39%):
- 4.1: ToolRegistry (206 lines, PR #31)
- 4.3: ExecutionEngine (459 lines, PR #32)
- 4.4: RecordingService (70 lines, PR #33)
- 4.5: LLMFactory (68 lines, PR #34)
- 4.6: Facade cleanup (this PR)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Deepfreezechill added a commit that referenced this pull request Apr 3, 2026
* feat(4.6): refactor OpenSpace into clean facade

Restructure initialize() from 190-line monolith into clean orchestration:
- initialize(): 70-line high-level flow with numbered steps
- _load_grounding_config(): config loading, backend scope resolution
- _setup_skill_engine(): skill registry, store, analyzer, evolver

Cleanup:
- Remove dead imports (asyncio, uuid — now in ExecutionEngine)
- Remove stale extraction comments (4.1/4.3 notes)
- Update from_container docstring (remove Phase 4 TODO — it's done)

Public API unchanged. All 1,356 tests pass.

P4 tool_layer.py decomposition summary (788 → 477 lines, -39%):
- 4.1: ToolRegistry (206 lines, PR #31)
- 4.3: ExecutionEngine (459 lines, PR #32)
- 4.4: RecordingService (70 lines, PR #33)
- 4.5: LLMFactory (68 lines, PR #34)
- 4.6: Facade cleanup (this PR)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: remove unused Path import (review finding)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore: remove stray main_tool_layer.py artifact

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Brian Krafft <bkrafft@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant