How openaiotlab/contextagent works
ContextAgent is a context-aware proactive LLM agent evaluated through in-context learning (ICL) or supervised fine-tuning (SFT). In ICL, a user selects a model and live or sandbox mode; inference uses a tool registry, and results can be scored. The repository also includes LLaMA-Factory as the documented SFT implementation and a substantial training/inference framework. The README and source index support the main workflow and imports, but many tool implementations and training internals were not excerpted, so those relationships are intentionally limited.
Main entry points: chat Chat engines · icl/inference.py Local ICL · inference_api.py API ICL · sft/inference.py SFT inference
Components 19
Agent evaluation
- Local ICL
src/icl/inference.py - API ICL
src/icl/inference_api.py - SFT inference
src/sft/inference.py - Run mode
src/config.py - Score results
src/calculate_scores.py - Inference utilities
src/utils.py
Context tools
- Tool registry
src/tool_registry.py - Context tools
src/tools
LLaMA-Factory
- Training workflows
LLaMA-Factory/src/llamafactory/train - Data processing
LLaMA-Factory/src/llamafactory/data - Chat engines
LLaMA-Factory/src/llamafactory/chat - Model loading
LLaMA-Factory/src/llamafactory/model - Quantization
LLaMA-Factory/src/llamafactory/model/model_utils/quantization.py - Run parameters
LLaMA-Factory/src/llamafactory/hparams - Inference API
LLaMA-Factory/src/llamafactory/api - Web interface
LLaMA-Factory/src/llamafactory/webui - Runtime support
LLaMA-Factory/src/llamafactory/extras
Other components
- Evaluator
- External APIs
Connections 24
- Evaluator → Local ICL: runs ICL
README.md - Evaluator → API ICL: runs API ICL
README.md - Evaluator → SFT inference: evaluates SFT
README.md - Local ICL → Tool registry: loads tools
src/icl/inference.py - API ICL → Tool registry: loads tools
src/icl/inference_api.py - SFT inference → Tool registry: loads tools
src/sft/inference.py - Local ICL → Run mode: uses mode
src/icl/inference.py - API ICL → Run mode: uses mode
src/icl/inference_api.py - SFT inference → Run mode: uses mode
src/sft/inference.py - Tool registry → Context tools: registers tools
src/tool_registry.py - Context tools → External APIs: calls integrations
README.md - Evaluator → Score results: scores runs
README.md - Local ICL → Inference utilities: uses utilities
src/icl/inference.py - API ICL → Inference utilities: uses utilities
src/icl/inference_api.py - SFT inference → Inference utilities: uses utilities
src/sft/inference.py - Evaluator → Training workflows: launches SFT
README.md - Training workflows → Data processing: uses data pipeline
- Training workflows → Model loading: loads models
- Chat engines → Data processing: uses templates
LLaMA-Factory/src/llamafactory/chat/base_engine.py - Chat engines → Model loading: loads model
LLaMA-Factory/src/llamafactory/chat/hf_engine.py - Chat engines → Quantization: configures quantization
LLaMA-Factory/src/llamafactory/chat/sglang_engine.py - Inference API → Chat engines: selects engine
LLaMA-Factory/src/llamafactory/api/app.py - Web interface → Chat engines: uses chat engine
LLaMA-Factory/src/llamafactory/webui/chatter.py - Chat engines → Run parameters: accepts arguments
LLaMA-Factory/src/llamafactory/chat/base_engine.py