ワンクリックで
arc-dyn-llm
JOB-251 — Why Arc<dyn LLM> over LLMClone, migration pattern, and correct LLM ownership model.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
JOB-251 — Why Arc<dyn LLM> over LLMClone, migration pattern, and correct LLM ownership model.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
AgentExecutor, ChatAgent (ReAct), OpenAIToolsAgent, and the Agent trait.
All Chain types — LLMChain, ConversationalChain, SequentialChain, StuffDocuments, ConversationalRetrievalQA, SqlDatabaseChain.
Trait conformance tests, property-based tests (proptest), fuzz targets, and boundary contracts for langchainx traits.
Core langchainx patterns — LLMChain, builder pattern, Chain trait, prompt macros, and basic invocation.
Constructing LLM backends (OpenAI, Claude, DeepSeek, Qwen, Ollama) and configuring CallOptions.
JOB-256 — blanket From impl, removing redundant Into impls, RwLock vs Mutex for memory.
| name | arc-dyn-llm |
| description | JOB-251 — Why Arc<dyn LLM> over LLMClone, migration pattern, and correct LLM ownership model. |
LLMClone exists solely because dyn LLM is not Clone:
// CURRENT — anti-pattern
pub trait LLMClone {
fn clone_box(&self) -> Box<dyn LLM>;
}
pub trait LLM: Sync + Send + LLMClone { ... }
// Used only in two places:
let stuff_chain = StuffDocumentBuilder::new().llm(llm.clone_box());
let condense_chain = CondenseQuestionGeneratorChain::new(llm.clone_box());
clone_box() allocates a new Box on every call. Every backend must also derive(Clone).
use std::sync::Arc;
use langchainx::language_models::llm::LLM;
// Cheap clone — just an atomic ref count increment
let llm: Arc<dyn LLM> = Arc::new(Claude::new());
let llm2 = Arc::clone(&llm); // no Box allocation, no clone_box()
// Both chains share the same LLM instance
let stuff_chain = StuffDocumentBuilder::new().llm(Arc::clone(&llm));
let condense_chain = CondenseQuestionGeneratorChain::new(Arc::clone(&llm));
## Current Workaround (until JOB-251 is resolved)
clone_box() still works today. If you must clone an LLM to pass to two builders:
// Acceptable today — will be removed when JOB-251 is implemented
let llm: Box<dyn LLM> = Box::new(OpenAI::default());
let stuff = StuffDocumentBuilder::new().llm(llm.clone_box()).build()?;
let condense = CondenseQuestionGeneratorChain::new(llm.clone_box());
Do NOT add new code that introduces new clone_box() call sites. Prefer Arc.
LLMClone supertrait from LLM definitionimpl<T: LLM + Clone> LLMClone for TBox<dyn LLM> fields → Arc<dyn LLM> in all chain structsFrom<L> for Box<dyn LLM> → From<L> for Arc<dyn LLM>llm.clone_box() call sites with Arc::clone(&llm).llm() method signatures to accept impl Into<Arc<dyn LLM>>