Skip to content

Commit d549289

Browse files
authored
Merge pull request #26 from Lixtt/fix/tool-output-config-docs
Fix tool output limits and config docs
2 parents 7701f60 + a764987 commit d549289

12 files changed

Lines changed: 343 additions & 85 deletions

File tree

README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ npm install @a3s-lab/code
2323

2424
## Quick Start
2525

26-
**1. Create an agent config** (`agent.hcl`):
26+
**1. Create an agent config** (`agent.acl`; legacy `.hcl` filenames still work):
2727

2828
```hcl
2929
default_model = "anthropic/claude-sonnet-4-20250514"
3030
31-
providers {
32-
name = "anthropic"
33-
api_key = env("ANTHROPIC_API_KEY")
31+
providers "anthropic" {
32+
apiKey = env("ANTHROPIC_API_KEY")
3433
}
3534
```
3635

@@ -39,7 +38,7 @@ providers {
3938
```python
4039
from a3s_code import Agent
4140

42-
agent = Agent.create("agent.hcl")
41+
agent = Agent.create("agent.acl")
4342
session = agent.session("/my-project")
4443

4544
result = session.send("Find all places where we handle authentication errors")
@@ -49,7 +48,7 @@ print(result.text)
4948
```typescript
5049
import { Agent } from '@a3s-lab/code';
5150

52-
const agent = await Agent.create('agent.hcl');
51+
const agent = await Agent.create('agent.acl');
5352
const session = agent.session('/my-project');
5453

5554
const result = await session.send('Find all places where we handle authentication errors');
@@ -300,14 +299,16 @@ Sessions intercept slash commands:
300299

301300
## Configuration
302301

303-
**HCL format:**
302+
The config language is ACL (Agent Configuration Language). It is HCL-like and
303+
the loader still accepts existing `.hcl` filenames and HCL-style
304+
`providers { name = "..." }` blocks, but new configs should use `.acl` and
305+
labeled provider/model blocks.
304306

305307
```hcl
306308
default_model = "anthropic/claude-sonnet-4-20250514"
307309
308-
providers {
309-
name = "anthropic"
310-
api_key = env("ANTHROPIC_API_KEY")
310+
providers "anthropic" {
311+
apiKey = env("ANTHROPIC_API_KEY")
311312
}
312313
313314
mcp_servers = []
@@ -333,7 +334,7 @@ ahp = {
333334
```
334335
Agent (facade — config-driven, workspace-independent)
335336
├── LlmClient (Anthropic / OpenAI / compatible)
336-
├── CodeConfig (HCL / JSON)
337+
├── CodeConfig (ACL-compatible config; legacy .hcl filenames accepted)
337338
├── SessionManager (multi-session support)
338339
│ └── AgentSession (workspace-bound)
339340
│ └── AgentLoop (core execution engine)

core/src/agent_api.rs

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,9 @@ impl std::fmt::Debug for Agent {
630630
}
631631

632632
impl Agent {
633-
/// Create from a config file path or inline HCL string.
633+
/// Create from a config file path or inline ACL-compatible string.
634634
///
635-
/// Auto-detects: `.hcl` file path vs inline HCL.
635+
/// Auto-detects: `.acl`/legacy `.hcl` file path vs inline ACL-compatible config.
636636
pub async fn new(config_source: impl Into<String>) -> Result<Self> {
637637
let source = config_source.into();
638638

@@ -652,7 +652,7 @@ impl Agent {
652652

653653
let config = if matches!(
654654
path.extension().and_then(|ext| ext.to_str()),
655-
Some("hcl" | "json")
655+
Some("acl" | "hcl")
656656
) {
657657
if !path.exists() {
658658
return Err(CodeError::Config(format!(
@@ -663,34 +663,24 @@ impl Agent {
663663

664664
CodeConfig::from_file(path)
665665
.with_context(|| format!("Failed to load config: {}", path.display()))?
666-
} else if matches!(path.extension().and_then(|ext| ext.to_str()), Some("acl")) {
667-
// Load .acl file
668-
if !path.exists() {
669-
return Err(CodeError::Config(format!(
670-
"Config file not found: {}",
671-
path.display()
672-
)));
673-
}
674-
let content = std::fs::read_to_string(path)
675-
.map_err(|e| CodeError::Config(format!("Failed to read ACL file: {}", e)))?;
676-
CodeConfig::from_acl(&content)
677-
.with_context(|| format!("Failed to parse ACL config: {}", path.display()))?
678666
} else if source.trim().starts_with('{') {
679-
// Try to parse as JSON string
680-
serde_json::from_str(&source)
681-
.map_err(|e| CodeError::Config(format!("Failed to parse JSON config: {}", e)))?
682-
} else if source.trim().starts_with("providers \"") {
683-
// ACL string (starts with ACL labeled block like providers "openai" { })
684-
CodeConfig::from_acl(&source).context("Failed to parse config as ACL string")?
667+
return Err(CodeError::Config(
668+
"JSON config is not supported; use ACL-compatible .acl/.hcl config".into(),
669+
)
670+
.into());
671+
} else if matches!(path.extension().and_then(|ext| ext.to_str()), Some("json")) {
672+
return Err(CodeError::Config(
673+
"JSON config files are not supported; use .acl or legacy .hcl".into(),
674+
)
675+
.into());
685676
} else {
686-
// Try to parse as ACL string (legacy format without quotes)
687677
CodeConfig::from_acl(&source).context("Failed to parse config as ACL string")?
688678
};
689679

690680
Self::from_config(config).await
691681
}
692682

693-
/// Create from a config file path or inline HCL string.
683+
/// Create from a config file path or inline ACL-compatible string.
694684
///
695685
/// Alias for [`Agent::new()`] — provides a consistent API with
696686
/// the Python and Node.js SDKs.
@@ -3382,7 +3372,7 @@ dir content
33823372
async fn test_new_with_existing_hcl_file_uses_file_loading() {
33833373
let temp_dir = tempfile::tempdir().unwrap();
33843374
let config_path = temp_dir.path().join("agent.hcl");
3385-
std::fs::write(&config_path, "this is not valid hcl").unwrap();
3375+
std::fs::write(&config_path, "this is not valid acl").unwrap();
33863376

33873377
let err = Agent::new(config_path.display().to_string())
33883378
.await
@@ -3391,7 +3381,7 @@ dir content
33913381

33923382
assert!(msg.contains("Failed to load config"));
33933383
assert!(msg.contains("agent.hcl"));
3394-
assert!(!msg.contains("Failed to parse config as HCL string"));
3384+
assert!(!msg.contains("Failed to parse config as ACL string"));
33953385
}
33963386

33973387
#[tokio::test]
@@ -3406,7 +3396,7 @@ dir content
34063396

34073397
assert!(msg.contains("Config file not found"));
34083398
assert!(msg.contains("agent.hcl"));
3409-
assert!(!msg.contains("Failed to parse config as HCL string"));
3399+
assert!(!msg.contains("Failed to parse config as ACL string"));
34103400
}
34113401

34123402
#[test]

0 commit comments

Comments
 (0)