web-cortex-framework 2.3.0__tar.gz → 2.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/Cargo.lock +2 -2
  2. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/Cargo.toml +1 -1
  3. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/PKG-INFO +2 -2
  4. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/README.md +1 -1
  5. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/agent/provider.rs +66 -37
  6. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/agent.rs +1 -0
  7. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/flow.rs +1 -0
  8. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/manifest.rs +12 -0
  9. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-py/src/behaviour.rs +4 -0
  10. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-py/src/lib.rs +2 -0
  11. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/pyproject.toml +1 -1
  12. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/__init__.py +1 -1
  13. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/app.py +21 -0
  14. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/LICENSE +0 -0
  15. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/Cargo.toml +0 -0
  16. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/agent/registry.rs +0 -0
  17. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/agent/session.rs +0 -0
  18. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/agent/vision.rs +0 -0
  19. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/app.rs +0 -0
  20. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/audit.rs +0 -0
  21. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/auth.rs +0 -0
  22. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/bridge.rs +0 -0
  23. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/context.rs +0 -0
  24. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/db.rs +0 -0
  25. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/devices.rs +0 -0
  26. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/files.rs +0 -0
  27. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/http.rs +0 -0
  28. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/ledger.rs +0 -0
  29. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/lib.rs +0 -0
  30. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/mcp.rs +0 -0
  31. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/middleware.rs +0 -0
  32. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/openapi.rs +0 -0
  33. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/router.rs +0 -0
  34. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/server.rs +0 -0
  35. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/templates.rs +0 -0
  36. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/typegen.rs +0 -0
  37. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-core/src/ws.rs +0 -0
  38. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/crates/webcortex-py/Cargo.toml +0 -0
  39. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/_bridge.py +0 -0
  40. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/cli.py +0 -0
  41. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/client.py +0 -0
  42. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/contextpack.py +0 -0
  43. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/media.py +0 -0
  44. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/schema.py +0 -0
  45. {web_cortex_framework-2.3.0 → web_cortex_framework-2.4.0}/python/webcortex/starters.py +0 -0
@@ -2661,7 +2661,7 @@ dependencies = [
2661
2661
 
2662
2662
  [[package]]
2663
2663
  name = "webcortex-core"
2664
- version = "2.3.0"
2664
+ version = "2.4.0"
2665
2665
  dependencies = [
2666
2666
  "base64 0.23.1",
2667
2667
  "bytes",
@@ -2689,7 +2689,7 @@ dependencies = [
2689
2689
 
2690
2690
  [[package]]
2691
2691
  name = "webcortex-py"
2692
- version = "2.3.0"
2692
+ version = "2.4.0"
2693
2693
  dependencies = [
2694
2694
  "bytes",
2695
2695
  "futures",
@@ -3,7 +3,7 @@ members = ["crates/webcortex-core", "crates/webcortex-py"]
3
3
  resolver = "3"
4
4
 
5
5
  [workspace.package]
6
- version = "2.3.0"
6
+ version = "2.4.0"
7
7
  edition = "2024"
8
8
  license = "Apache-2.0"
9
9
  rust-version = "1.85"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: web-cortex-framework
3
- Version: 2.3.0
3
+ Version: 2.4.0
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -510,7 +510,7 @@ tested, the known limits, and what v2 added to the surface.
510
510
 
511
511
  ## Status
512
512
 
513
- v2.3.0. Working and tested: the manifest IR, router, native ops (static /
513
+ v2.4.0. Working and tested: the manifest IR, router, native ops (static /
514
514
  query / proxy / page / files / flow), the free-threaded Python bridge,
515
515
  authentication and scopes, rate limiting, CORS, security headers, graceful
516
516
  shutdown, Behaviours with concurrent leaves, the agent runtime with handoffs,
@@ -482,7 +482,7 @@ tested, the known limits, and what v2 added to the surface.
482
482
 
483
483
  ## Status
484
484
 
485
- v2.3.0. Working and tested: the manifest IR, router, native ops (static /
485
+ v2.4.0. Working and tested: the manifest IR, router, native ops (static /
486
486
  query / proxy / page / files / flow), the free-threaded Python bridge,
487
487
  authentication and scopes, rate limiting, CORS, security headers, graceful
488
488
  shutdown, Behaviours with concurrent leaves, the agent runtime with handoffs,
@@ -331,43 +331,7 @@ impl ModelProvider for OpenAiCompatProvider {
331
331
  ) -> BoxFuture<'a, Result<ProviderResponse, String>> {
332
332
  Box::pin(async move {
333
333
  let agent = req.agent;
334
- let mut messages: Vec<Value> = Vec::new();
335
- let system = full_system(req);
336
- if !system.is_empty() {
337
- messages.push(json!({"role": "system", "content": system}));
338
- }
339
- for m in &req.conversation.messages {
340
- messages.extend(to_openai_messages(&m.role, &m.content));
341
- }
342
-
343
- let mut body = json!({
344
- "model": agent.model,
345
- "max_tokens": agent.max_tokens,
346
- "messages": messages,
347
- });
348
- if let Some(t) = agent.temperature {
349
- body["temperature"] = json!(t);
350
- }
351
- if !req.tools.is_empty() {
352
- body["tools"] = Value::Array(
353
- req.tools
354
- .iter()
355
- .map(|t| {
356
- json!({
357
- "type": "function",
358
- "function": {
359
- "name": t.name,
360
- "description": t.description,
361
- "parameters": t.input_schema,
362
- }
363
- })
364
- })
365
- .collect(),
366
- );
367
- if let Some(name) = req.force_tool {
368
- body["tool_choice"] = json!({"type": "function", "function": {"name": name}});
369
- }
370
- }
334
+ let body = openai_body(req);
371
335
 
372
336
  let mut builder = self
373
337
  .client
@@ -402,6 +366,54 @@ impl ModelProvider for OpenAiCompatProvider {
402
366
  }
403
367
  }
404
368
 
369
+ /// The Chat Completions request for one step.
370
+ pub fn openai_body(req: &CompletionRequest) -> Value {
371
+ let agent = req.agent;
372
+ let mut messages: Vec<Value> = Vec::new();
373
+ let system = full_system(req);
374
+ if !system.is_empty() {
375
+ messages.push(json!({"role": "system", "content": system}));
376
+ }
377
+ for m in &req.conversation.messages {
378
+ messages.extend(to_openai_messages(&m.role, &m.content));
379
+ }
380
+
381
+ let mut body = json!({
382
+ "model": agent.model,
383
+ "max_tokens": agent.max_tokens,
384
+ "messages": messages,
385
+ });
386
+ if let Some(t) = agent.temperature {
387
+ body["temperature"] = json!(t);
388
+ }
389
+ // Only when the app set it. `none` is how a local thinking model (Qwen,
390
+ // Gemma 4, MiniCPM through Ollama) is told to answer instead of deliberate.
391
+ if let Some(r) = &agent.reasoning {
392
+ body["reasoning_effort"] = json!(r);
393
+ }
394
+ if !req.tools.is_empty() {
395
+ body["tools"] = Value::Array(
396
+ req.tools
397
+ .iter()
398
+ .map(|t| {
399
+ json!({
400
+ "type": "function",
401
+ "function": {
402
+ "name": t.name,
403
+ "description": t.description,
404
+ "parameters": t.input_schema,
405
+ }
406
+ })
407
+ })
408
+ .collect(),
409
+ );
410
+ if let Some(name) = req.force_tool {
411
+ body["tool_choice"] = json!({"type": "function", "function": {"name": name}});
412
+ }
413
+ }
414
+ body
415
+ }
416
+
405
417
  /// Translate one canonical (Anthropic-shaped) message into OpenAI messages.
406
418
  /// A user turn holding tool results becomes one `tool` message per result.
407
419
  ///
@@ -1033,6 +1045,23 @@ mod tests {
1033
1045
  assert_eq!(body(&agent)["temperature"], json!(0.2f32));
1034
1046
  }
1035
1047
 
1048
+ #[test]
1049
+ fn reasoning_is_sent_as_reasoning_effort_only_on_the_openai_format() {
1050
+ let mut agent: AgentDef =
1051
+ serde_json::from_value(json!({"name": "a", "model": "ollama/qwen3.5:4b"})).unwrap();
1052
+ let conversation = Conversation::default();
1053
+ fn request<'a>(agent: &'a AgentDef, conversation: &'a Conversation) -> CompletionRequest<'a> {
1054
+ CompletionRequest { agent, conversation, tools: &[], force_tool: None, system_suffix: "" }
1055
+ }
1056
+ assert!(openai_body(&request(&agent, &conversation)).get("reasoning_effort").is_none());
1057
+ agent.reasoning = Some("none".into());
1058
+ assert_eq!(openai_body(&request(&agent, &conversation))["reasoning_effort"], json!("none"));
1059
+ assert!(
1060
+ anthropic_body(&request(&agent, &conversation)).get("reasoning_effort").is_none(),
1061
+ "the Anthropic format has no such field"
1062
+ );
1063
+ }
1064
+
1036
1065
  #[test]
1037
1066
  fn parses_a_text_response() {
1038
1067
  let payload = json!({
@@ -854,6 +854,7 @@ impl AgentRuntime {
854
854
  token_budget: None,
855
855
  scopes: Vec::new(),
856
856
  temperature: None,
857
+ reasoning: None,
857
858
  max_tokens: 4096,
858
859
  handoffs: Vec::new(),
859
860
  context: Vec::new(),
@@ -306,6 +306,7 @@ async fn classify(
306
306
  token_budget: None,
307
307
  scopes: Vec::new(),
308
308
  temperature: None,
309
+ reasoning: None,
309
310
  max_tokens: 256,
310
311
  handoffs: Vec::new(),
311
312
  context: Vec::new(),
@@ -626,6 +626,12 @@ pub struct BehaviourDef {
626
626
  /// Sent only when set: recent Anthropic models reject sampling parameters.
627
627
  #[serde(default)]
628
628
  pub temperature: Option<f32>,
629
+ /// How hard the model may think before answering: `none`, `low`, `medium`
630
+ /// or `high`. Sent as `reasoning_effort` on the OpenAI wire format, where
631
+ /// `none` is what makes a local thinking model answer in a second rather
632
+ /// than a minute. Not sent to Anthropic.
633
+ #[serde(default)]
634
+ pub reasoning: Option<String>,
629
635
  #[serde(default)]
630
636
  pub input_schema: Option<serde_json::Value>,
631
637
  /// Context providers resolved on demand via `ctx.context(name)`.
@@ -1011,6 +1017,12 @@ pub struct AgentDef {
1011
1017
  /// Sent only when set: recent Anthropic models reject sampling parameters.
1012
1018
  #[serde(default)]
1013
1019
  pub temperature: Option<f32>,
1020
+ /// How hard the model may think before answering: `none`, `low`, `medium`
1021
+ /// or `high`. Sent as `reasoning_effort` on the OpenAI wire format (Ollama,
1022
+ /// vLLM, OpenAI); `none` is what makes a local thinking model answer in a
1023
+ /// second rather than a minute. Not sent to Anthropic.
1024
+ #[serde(default)]
1025
+ pub reasoning: Option<String>,
1014
1026
  #[serde(default = "default_max_tokens")]
1015
1027
  pub max_tokens: u32,
1016
1028
  /// Agents this one may hand the conversation to. Each becomes a
@@ -78,6 +78,7 @@ pub struct BehaviourContext {
78
78
  model: String,
79
79
  max_tokens: u32,
80
80
  temperature: Option<f32>,
81
+ reasoning: Option<String>,
81
82
 
82
83
  /// How deep this run already sits in the invocation chain. Tools called from
83
84
  /// here run one level deeper, which is what bounds a recursive behaviour.
@@ -114,6 +115,7 @@ impl BehaviourContext {
114
115
  model: String,
115
116
  max_tokens: u32,
116
117
  temperature: Option<f32>,
118
+ reasoning: Option<String>,
117
119
  depth: u32,
118
120
  budget: Arc<SharedBudget>,
119
121
  input: serde_json::Value,
@@ -136,6 +138,7 @@ impl BehaviourContext {
136
138
  model,
137
139
  max_tokens,
138
140
  temperature,
141
+ reasoning,
139
142
  depth,
140
143
  budget,
141
144
  input,
@@ -243,6 +246,7 @@ impl BehaviourContext {
243
246
  token_budget: None,
244
247
  scopes: Vec::new(),
245
248
  temperature: temperature.or(self.temperature),
249
+ reasoning: self.reasoning.clone(),
246
250
  max_tokens: max_tokens.unwrap_or(self.max_tokens),
247
251
  handoffs: Vec::new(),
248
252
  context: Vec::new(),
@@ -139,6 +139,7 @@ impl PyBridge for PythonBridge {
139
139
  def.model.clone(),
140
140
  def.max_tokens,
141
141
  def.temperature,
142
+ def.reasoning.clone(),
142
143
  depth,
143
144
  budget,
144
145
  input.clone(),
@@ -372,6 +373,7 @@ fn ask_model(
372
373
  token_budget: None,
373
374
  scopes: Vec::new(),
374
375
  temperature: None,
376
+ reasoning: None,
375
377
  max_tokens,
376
378
  handoffs: Vec::new(),
377
379
  context: Vec::new(),
@@ -7,7 +7,7 @@ build-backend = "maturin"
7
7
  # The split is for ergonomics, the same way djangorestframework imports as
8
8
  # `rest_framework`.
9
9
  name = "web-cortex-framework"
10
- version = "2.3.0"
10
+ version = "2.4.0"
11
11
  description = "A Rust-cored Python web framework where every route is also an agent tool."
12
12
  readme = "README.md"
13
13
  requires-python = ">=3.12"
@@ -18,7 +18,7 @@ from ._bridge import HTTPError, Request, Response, free_threaded
18
18
  from .app import WebCortex, Resource
19
19
  from .media import Image
20
20
 
21
- __version__ = "2.3.0"
21
+ __version__ = "2.4.0"
22
22
 
23
23
  __all__ = [
24
24
  "WebCortex",
@@ -42,6 +42,23 @@ class Resource:
42
42
  route_ids: list[int] = field(default_factory=list)
43
43
 
44
44
 
45
+ REASONING_LEVELS = ("none", "low", "medium", "high")
46
+
47
+
48
+ def _reasoning(value: str | None, who: str) -> str | None:
49
+ """`reasoning=` on an agent or behaviour: how hard the model may think before it answers.
50
+
51
+ Sent as `reasoning_effort` to OpenAI-compatible providers (Ollama, vLLM, LM Studio,
52
+ OpenAI); the Anthropic provider ignores it. `"none"` is the setting that makes a local
53
+ thinking model (Qwen 3.5, Gemma 4, MiniCPM) answer in a second instead of a minute.
54
+ """
55
+ if value is None:
56
+ return None
57
+ if value not in REASONING_LEVELS:
58
+ raise ValueError(f"{who}: reasoning must be one of {', '.join(REASONING_LEVELS)}, not {value!r}")
59
+ return value
60
+
61
+
45
62
  class WebCortex:
46
63
  def __init__(
47
64
  self,
@@ -1036,6 +1053,7 @@ class WebCortex:
1036
1053
  model: str = "default",
1037
1054
  max_tokens: int = 16_000,
1038
1055
  temperature: float | None = None,
1056
+ reasoning: str | None = None,
1039
1057
  expose_at: str | None = None,
1040
1058
  expose_scopes: Sequence[str] | None = None,
1041
1059
  tool: bool = True,
@@ -1113,6 +1131,7 @@ class WebCortex:
1113
1131
  "model": model,
1114
1132
  "max_tokens": max_tokens,
1115
1133
  "temperature": temperature,
1134
+ "reasoning": _reasoning(reasoning, f"behaviour {behaviour_name!r}"),
1116
1135
  "input_schema": input_schema,
1117
1136
  "context": list(context),
1118
1137
  }
@@ -1164,6 +1183,7 @@ class WebCortex:
1164
1183
  scopes: Sequence[str] = (),
1165
1184
  expose_scopes: Sequence[str] | None = None,
1166
1185
  temperature: float | None = None,
1186
+ reasoning: str | None = None,
1167
1187
  max_tokens: int = 16_000,
1168
1188
  cache: bool = True,
1169
1189
  context_window: int | None = None,
@@ -1259,6 +1279,7 @@ class WebCortex:
1259
1279
  "token_budget": token_budget,
1260
1280
  "scopes": list(scopes),
1261
1281
  "temperature": temperature,
1282
+ "reasoning": _reasoning(reasoning, f"agent {name!r}"),
1262
1283
  "max_tokens": max_tokens,
1263
1284
  "cache": bool(cache),
1264
1285
  "policy": {