codee-agent 0.9.0__py3-none-any.whl → 0.9.2__py3-none-any.whl
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.
- codee/admin.py +146 -22
- codee/admin_service.py +16 -4
- codee/executor.py +14 -10
- codee/lib/test_trigger_cron_skills.py +30 -15
- codee/lib/test_trigger_email_skills.py +2 -1
- codee/lib/trigger_aws_sqs_skills.py +4 -1
- codee/lib/trigger_cron_skills.py +8 -4
- codee/lib/trigger_email_skills.py +4 -1
- codee/lib/trigger_issue_skills.py +3 -0
- codee/test_admin.py +76 -5
- codee/test_admin_service.py +36 -6
- codee/test_executor.py +6 -4
- {codee_agent-0.9.0.dist-info → codee_agent-0.9.2.dist-info}/METADATA +1 -1
- {codee_agent-0.9.0.dist-info → codee_agent-0.9.2.dist-info}/RECORD +23 -23
- codee_agent_abstract/provider.py +18 -2
- codee_agent_claude_code/provider.py +2 -1
- codee_agent_codex/provider.py +2 -1
- codee_agent_github_copilot/provider.py +205 -4
- codee_agent_github_copilot/test.py +178 -4
- codee_agent_opencode/provider.py +2 -1
- {codee_agent-0.9.0.dist-info → codee_agent-0.9.2.dist-info}/WHEEL +0 -0
- {codee_agent-0.9.0.dist-info → codee_agent-0.9.2.dist-info}/entry_points.txt +0 -0
- {codee_agent-0.9.0.dist-info → codee_agent-0.9.2.dist-info}/licenses/LICENSE +0 -0
codee/admin.py
CHANGED
|
@@ -62,6 +62,14 @@ def _model_option(models: list["ModelOption"],
|
|
|
62
62
|
return None
|
|
63
63
|
|
|
64
64
|
|
|
65
|
+
def _effort_options(model: "ModelOption | None", effort: str) -> list[str]:
|
|
66
|
+
"""The levels ``model`` takes, plus ``effort`` when the model lacks it."""
|
|
67
|
+
options = list(model.efforts) if model else []
|
|
68
|
+
if effort and effort not in options:
|
|
69
|
+
options.append(effort)
|
|
70
|
+
return options
|
|
71
|
+
|
|
72
|
+
|
|
65
73
|
def _usage_row(account: Any) -> "ClaudeAccount":
|
|
66
74
|
"""One account's dashboard row, with its percentages rounded to whole numbers.
|
|
67
75
|
|
|
@@ -115,13 +123,18 @@ class ModelOption(BaseModel):
|
|
|
115
123
|
|
|
116
124
|
``efforts`` are the reasoning effort levels the model takes, empty when it
|
|
117
125
|
has none, and ``default_effort`` the one it runs at when the skill sets
|
|
118
|
-
none, empty when the agent doesn't say.
|
|
126
|
+
none, empty when the agent doesn't say. ``effort_label`` names levels that
|
|
127
|
+
aren't a reasoning effort (Copilot Auto's tiers), empty otherwise.
|
|
128
|
+
``context_tiers`` are ``[value, label]`` pairs for the context windows the
|
|
129
|
+
model offers, the default first, and empty when there is no choice.
|
|
119
130
|
"""
|
|
120
131
|
|
|
121
132
|
id: str
|
|
122
133
|
name: str
|
|
123
134
|
efforts: list[str] = []
|
|
124
135
|
default_effort: str = ""
|
|
136
|
+
effort_label: str = ""
|
|
137
|
+
context_tiers: list[list[str]] = []
|
|
125
138
|
|
|
126
139
|
|
|
127
140
|
class ConversationMessage(BaseModel):
|
|
@@ -375,6 +388,8 @@ class AdminState(rx.State):
|
|
|
375
388
|
skill_model: str = ""
|
|
376
389
|
# The skill's `effort:`, empty for the model's own default.
|
|
377
390
|
skill_effort: str = ""
|
|
391
|
+
# The skill's `x-codee-context-tier:`, empty for the default window.
|
|
392
|
+
skill_context_tier: str = ""
|
|
378
393
|
# The agent code the skill declares, empty for the default agent.
|
|
379
394
|
skill_agent: str = ""
|
|
380
395
|
skill_type: str = "knowledge"
|
|
@@ -586,15 +601,41 @@ class AdminState(rx.State):
|
|
|
586
601
|
effort the skill already carries is always listed, so a value written by
|
|
587
602
|
hand stays visible and can be cleared rather than being dropped unseen.
|
|
588
603
|
"""
|
|
604
|
+
return _effort_options(
|
|
605
|
+
_model_option(self.agent_models, self.skill_model),
|
|
606
|
+
self.skill_effort)
|
|
607
|
+
|
|
608
|
+
@rx.var
|
|
609
|
+
def skill_effort_choices(self) -> list[list[str]]:
|
|
610
|
+
"""``[value, label]`` for each effort option; a tier reads capitalized."""
|
|
611
|
+
model = _model_option(self.agent_models, self.skill_model)
|
|
612
|
+
tiered = bool(model and model.effort_label)
|
|
613
|
+
return [[option, option.capitalize() if tiered else option]
|
|
614
|
+
for option in _effort_options(model, self.skill_effort)]
|
|
615
|
+
|
|
616
|
+
@rx.var
|
|
617
|
+
def skill_effort_label(self) -> str:
|
|
618
|
+
"""The picker's title: what the picked model calls its levels."""
|
|
619
|
+
model = _model_option(self.agent_models, self.skill_model)
|
|
620
|
+
return (model.effort_label if model and model.effort_label
|
|
621
|
+
else "Reasoning effort")
|
|
622
|
+
|
|
623
|
+
@rx.var
|
|
624
|
+
def skill_effort_has_default(self) -> bool:
|
|
625
|
+
"""Whether the picker offers "Model default".
|
|
626
|
+
|
|
627
|
+
A tier always has a value, so for a tiered model the picker shows its
|
|
628
|
+
default level selected instead.
|
|
629
|
+
"""
|
|
589
630
|
model = _model_option(self.agent_models, self.skill_model)
|
|
590
|
-
|
|
591
|
-
if self.skill_effort and self.skill_effort not in options:
|
|
592
|
-
options.append(self.skill_effort)
|
|
593
|
-
return options
|
|
631
|
+
return not (model and model.effort_label)
|
|
594
632
|
|
|
595
633
|
@rx.var
|
|
596
634
|
def skill_effort_value(self) -> str:
|
|
597
635
|
"""The effort picker's value; the select can't hold an empty one."""
|
|
636
|
+
model = _model_option(self.agent_models, self.skill_model)
|
|
637
|
+
if not self.skill_effort and model and model.effort_label:
|
|
638
|
+
return model.default_effort
|
|
598
639
|
return self.skill_effort or EFFORT_DEFAULT
|
|
599
640
|
|
|
600
641
|
@rx.var
|
|
@@ -612,6 +653,29 @@ class AdminState(rx.State):
|
|
|
612
653
|
return bool(self.skill_effort) and (
|
|
613
654
|
model is None or self.skill_effort not in model.efforts)
|
|
614
655
|
|
|
656
|
+
@rx.var
|
|
657
|
+
def skill_context_choices(self) -> list[list[str]]:
|
|
658
|
+
"""``[value, label]`` for each context window the picked model offers.
|
|
659
|
+
|
|
660
|
+
Empty, and the picker hidden, for a model with no choice of window. A
|
|
661
|
+
tier the skill already carries is always listed, as with effort.
|
|
662
|
+
"""
|
|
663
|
+
model = _model_option(self.agent_models, self.skill_model)
|
|
664
|
+
choices = [list(tier) for tier in model.context_tiers] if model else []
|
|
665
|
+
if (self.skill_context_tier
|
|
666
|
+
and all(value != self.skill_context_tier
|
|
667
|
+
for value, _ in choices)):
|
|
668
|
+
choices.append([self.skill_context_tier, self.skill_context_tier])
|
|
669
|
+
return choices
|
|
670
|
+
|
|
671
|
+
@rx.var
|
|
672
|
+
def skill_context_value(self) -> str:
|
|
673
|
+
"""The context picker's value: the skill's tier, or the default one."""
|
|
674
|
+
model = _model_option(self.agent_models, self.skill_model)
|
|
675
|
+
if self.skill_context_tier or not (model and model.context_tiers):
|
|
676
|
+
return self.skill_context_tier
|
|
677
|
+
return model.context_tiers[0][0]
|
|
678
|
+
|
|
615
679
|
@rx.var
|
|
616
680
|
def custom_model_query(self) -> str:
|
|
617
681
|
"""The search text when it names no known model, so it can be used as-is."""
|
|
@@ -680,6 +744,7 @@ class AdminState(rx.State):
|
|
|
680
744
|
self.skill_agent = agent
|
|
681
745
|
self.skill_model = ""
|
|
682
746
|
self.skill_effort = ""
|
|
747
|
+
self.skill_context_tier = ""
|
|
683
748
|
self.model_query = ""
|
|
684
749
|
return AdminState.load_agent_models
|
|
685
750
|
|
|
@@ -689,19 +754,31 @@ class AdminState(rx.State):
|
|
|
689
754
|
def choose_model(self, model_id: str) -> None:
|
|
690
755
|
"""Pick a model from the list, or use whatever the user typed.
|
|
691
756
|
|
|
692
|
-
An effort the newly picked model is known not to
|
|
693
|
-
it would only make that model's run fail. One
|
|
694
|
-
either way for stays, and the picker keeps
|
|
757
|
+
An effort or context window the newly picked model is known not to
|
|
758
|
+
take is cleared, since it would only make that model's run fail. One
|
|
759
|
+
the catalog can't vouch either way for stays, and the picker keeps
|
|
760
|
+
showing it.
|
|
695
761
|
"""
|
|
696
762
|
self.skill_model = model_id.strip()
|
|
697
763
|
self.model_query = ""
|
|
698
764
|
model = _model_option(self.agent_models, self.skill_model)
|
|
699
|
-
if model is
|
|
765
|
+
if model is None:
|
|
766
|
+
return
|
|
767
|
+
if self.skill_effort not in model.efforts:
|
|
700
768
|
self.skill_effort = ""
|
|
769
|
+
if all(value != self.skill_context_tier
|
|
770
|
+
for value, _ in model.context_tiers):
|
|
771
|
+
self.skill_context_tier = ""
|
|
701
772
|
|
|
702
773
|
def set_skill_effort(self, value: str) -> None:
|
|
703
774
|
self.skill_effort = "" if value == EFFORT_DEFAULT else value
|
|
704
775
|
|
|
776
|
+
def set_skill_context_tier(self, value: str) -> None:
|
|
777
|
+
"""Pick a context window; the model's default one is stored as unset."""
|
|
778
|
+
model = _model_option(self.agent_models, self.skill_model)
|
|
779
|
+
default = model.context_tiers[0][0] if model and model.context_tiers else ""
|
|
780
|
+
self.skill_context_tier = "" if value == default else value
|
|
781
|
+
|
|
705
782
|
@rx.event(background=True)
|
|
706
783
|
async def load_agent_models(self) -> None:
|
|
707
784
|
"""Fetch the catalog of the agent this skill runs on, off the event loop.
|
|
@@ -778,6 +855,7 @@ class AdminState(rx.State):
|
|
|
778
855
|
self.skill_description = skill["description"]
|
|
779
856
|
self.skill_model = skill["model"]
|
|
780
857
|
self.skill_effort = skill["effort"]
|
|
858
|
+
self.skill_context_tier = skill["context_tier"]
|
|
781
859
|
self.skill_agent = skill["agent"]
|
|
782
860
|
self.model_query = ""
|
|
783
861
|
self.skill_type = skill["type"]
|
|
@@ -803,6 +881,7 @@ class AdminState(rx.State):
|
|
|
803
881
|
"description": self.skill_description,
|
|
804
882
|
"model": self.skill_model,
|
|
805
883
|
"effort": self.skill_effort,
|
|
884
|
+
"context_tier": self.skill_context_tier,
|
|
806
885
|
"agent": self.skill_agent,
|
|
807
886
|
"type": self.skill_type,
|
|
808
887
|
"cron": self.skill_cron,
|
|
@@ -2696,21 +2775,25 @@ def effort_picker() -> rx.Component:
|
|
|
2696
2775
|
return rx.cond(
|
|
2697
2776
|
AdminState.skill_effort_options.length() > 0,
|
|
2698
2777
|
rx.box(field(
|
|
2699
|
-
|
|
2778
|
+
AdminState.skill_effort_label,
|
|
2700
2779
|
rx.select.root(
|
|
2701
2780
|
rx.select.trigger(width="100%"),
|
|
2702
2781
|
rx.select.content(
|
|
2703
|
-
rx.
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2782
|
+
rx.cond(AdminState.skill_effort_has_default,
|
|
2783
|
+
rx.select.item(
|
|
2784
|
+
AdminState.skill_effort_default_label,
|
|
2785
|
+
value=EFFORT_DEFAULT)),
|
|
2786
|
+
rx.foreach(AdminState.skill_effort_choices,
|
|
2787
|
+
lambda choice: rx.select.item(
|
|
2788
|
+
choice[1], value=choice[0]))),
|
|
2708
2789
|
value=AdminState.skill_effort_value,
|
|
2709
2790
|
on_change=AdminState.set_skill_effort),
|
|
2710
2791
|
rx.text(
|
|
2711
2792
|
rx.cond(
|
|
2712
2793
|
AdminState.skill_effort == "",
|
|
2713
|
-
|
|
2794
|
+
rx.cond(AdminState.skill_effort_has_default,
|
|
2795
|
+
"Runs at the model's own effort.",
|
|
2796
|
+
"Runs on the default tier."),
|
|
2714
2797
|
rx.cond(
|
|
2715
2798
|
AdminState.skill_effort_unlisted,
|
|
2716
2799
|
rx.fragment(
|
|
@@ -2725,6 +2808,32 @@ def effort_picker() -> rx.Component:
|
|
|
2725
2808
|
flex="1", min_width="0"))
|
|
2726
2809
|
|
|
2727
2810
|
|
|
2811
|
+
def context_picker() -> rx.Component:
|
|
2812
|
+
"""Context window for the picked model, shown only when it offers a choice."""
|
|
2813
|
+
return rx.cond(
|
|
2814
|
+
AdminState.skill_context_choices.length() > 0,
|
|
2815
|
+
rx.box(field(
|
|
2816
|
+
"Context window",
|
|
2817
|
+
rx.select.root(
|
|
2818
|
+
rx.select.trigger(width="100%"),
|
|
2819
|
+
rx.select.content(
|
|
2820
|
+
rx.foreach(AdminState.skill_context_choices,
|
|
2821
|
+
lambda choice: rx.select.item(
|
|
2822
|
+
choice[1], value=choice[0]))),
|
|
2823
|
+
value=AdminState.skill_context_value,
|
|
2824
|
+
on_change=AdminState.set_skill_context_tier),
|
|
2825
|
+
rx.text(
|
|
2826
|
+
rx.cond(
|
|
2827
|
+
AdminState.skill_context_tier == "",
|
|
2828
|
+
"Runs on the model's default window.",
|
|
2829
|
+
rx.fragment("Saved as ",
|
|
2830
|
+
rx.code("x-codee-context-tier: ",
|
|
2831
|
+
AdminState.skill_context_tier),
|
|
2832
|
+
" in the skill frontmatter.")),
|
|
2833
|
+
color=MUTED, font_size="0.82rem")),
|
|
2834
|
+
flex="1", min_width="0"))
|
|
2835
|
+
|
|
2836
|
+
|
|
2728
2837
|
def delete_skill_dialog() -> rx.Component:
|
|
2729
2838
|
return rx.alert_dialog.root(
|
|
2730
2839
|
rx.alert_dialog.trigger(
|
|
@@ -2765,10 +2874,11 @@ def skill_editor() -> rx.Component:
|
|
|
2765
2874
|
on_change=AdminState.set_skill_description,
|
|
2766
2875
|
width="100%", min_height="5rem")),
|
|
2767
2876
|
rx.grid(agent_picker(),
|
|
2768
|
-
# Effort
|
|
2769
|
-
# when the picked model has
|
|
2877
|
+
# Effort and context window share the model's column; the
|
|
2878
|
+
# model takes all of it when the picked model has neither.
|
|
2770
2879
|
rx.flex(rx.box(model_picker(), flex="1", min_width="0"),
|
|
2771
2880
|
effort_picker(),
|
|
2881
|
+
context_picker(),
|
|
2772
2882
|
direction=rx.breakpoints(initial="column", sm="row"),
|
|
2773
2883
|
gap="1rem", align="start", width="100%"),
|
|
2774
2884
|
columns=rx.breakpoints(initial="1", md="2"), gap="1rem",
|
|
@@ -3874,8 +3984,8 @@ def claude_code_setting() -> rx.Component:
|
|
|
3874
3984
|
|
|
3875
3985
|
def github_copilot_setting() -> rx.Component:
|
|
3876
3986
|
"""Settings used only by GitHub Copilot CLI runs."""
|
|
3877
|
-
return rx.
|
|
3878
|
-
rx.
|
|
3987
|
+
return rx.vstack(
|
|
3988
|
+
rx.text("GitHub Copilot", font_size="0.9rem", font_weight="600"),
|
|
3879
3989
|
field(
|
|
3880
3990
|
"Prompt prefix",
|
|
3881
3991
|
rx.text_area(
|
|
@@ -3891,7 +4001,18 @@ def github_copilot_setting() -> rx.Component:
|
|
|
3891
4001
|
font_size="0.82rem",
|
|
3892
4002
|
),
|
|
3893
4003
|
),
|
|
3894
|
-
|
|
4004
|
+
spacing="3", width="100%")
|
|
4005
|
+
|
|
4006
|
+
|
|
4007
|
+
def coding_agent_advanced() -> rx.Component:
|
|
4008
|
+
"""Collapsed by default: agent-specific tweaks most setups never touch."""
|
|
4009
|
+
return rx.accordion.root(
|
|
4010
|
+
rx.accordion.item(
|
|
4011
|
+
header=rx.text("Advanced", font_size="0.9rem", font_weight="600"),
|
|
4012
|
+
content=rx.box(github_copilot_setting(), padding="1rem 0.25rem",
|
|
4013
|
+
width="100%"),
|
|
4014
|
+
),
|
|
4015
|
+
type="single", collapsible=True, variant="ghost", width="100%")
|
|
3895
4016
|
|
|
3896
4017
|
|
|
3897
4018
|
def conversation_message(message: ConversationMessage) -> rx.Component:
|
|
@@ -4065,13 +4186,16 @@ def settings_page() -> rx.Component:
|
|
|
4065
4186
|
type="number", min=1, width="100%"),
|
|
4066
4187
|
rx.text("How many task agents may run at once.",
|
|
4067
4188
|
color=MUTED, font_size="0.82rem")),
|
|
4189
|
+
# Only Copilot has advanced settings so far, so the section
|
|
4190
|
+
# would be empty on a machine without it.
|
|
4191
|
+
coding_agent_advanced() if GITHUB_COPILOT_AVAILABLE
|
|
4192
|
+
else rx.fragment(),
|
|
4068
4193
|
spacing="4", width="100%"),
|
|
4069
4194
|
padding="1.25rem", background=SURFACE, border=BORDER, width="100%"),
|
|
4070
4195
|
# Decided when the page is built rather than with an rx.cond, because
|
|
4071
4196
|
# which agents a machine has is not state: there is no event that could
|
|
4072
4197
|
# ever flip it, and nothing on the page should be able to.
|
|
4073
4198
|
claude_code_setting() if CLAUDE_CODE_AVAILABLE else rx.fragment(),
|
|
4074
|
-
github_copilot_setting() if GITHUB_COPILOT_AVAILABLE else rx.fragment(),
|
|
4075
4199
|
rx.box(
|
|
4076
4200
|
rx.heading("Tasks provider", size="4", margin_bottom="1rem"),
|
|
4077
4201
|
field("Provider", rx.select(["jira", "azure_devops"], value=AdminState.tasks_provider,
|
codee/admin_service.py
CHANGED
|
@@ -88,6 +88,7 @@ MANAGED = {
|
|
|
88
88
|
"model",
|
|
89
89
|
"effort",
|
|
90
90
|
"disable-model-invocation",
|
|
91
|
+
"x-codee-context-tier",
|
|
91
92
|
"cron",
|
|
92
93
|
"x-codee-agent",
|
|
93
94
|
"x-codee-trigger",
|
|
@@ -638,6 +639,8 @@ def _skill_run_summary(
|
|
|
638
639
|
]
|
|
639
640
|
if skill.effort:
|
|
640
641
|
lines.append(f"Effort: {skill.effort}")
|
|
642
|
+
if skill.context_tier:
|
|
643
|
+
lines.append(f"Context: {skill.context_tier}")
|
|
641
644
|
lines.append(f"Skill: {skill.name}")
|
|
642
645
|
return lines
|
|
643
646
|
|
|
@@ -977,6 +980,8 @@ class AdminService:
|
|
|
977
980
|
"agent": _agent_code(frontmatter.get("x-codee-agent", "")),
|
|
978
981
|
"model": str(frontmatter.get("model", "") or "").strip(),
|
|
979
982
|
"effort": str(frontmatter.get("effort", "") or "").strip(),
|
|
983
|
+
"context_tier": str(frontmatter.get(
|
|
984
|
+
"x-codee-context-tier", "") or "").strip(),
|
|
980
985
|
"issue_status": _format_issue_status(
|
|
981
986
|
frontmatter.get("x-codee-issue-status", [])
|
|
982
987
|
),
|
|
@@ -1029,7 +1034,9 @@ class AdminService:
|
|
|
1029
1034
|
self._models_cache[agent_key] = models
|
|
1030
1035
|
return [{"id": model.id, "name": model.name,
|
|
1031
1036
|
"efforts": list(model.efforts),
|
|
1032
|
-
"default_effort": model.default_effort
|
|
1037
|
+
"default_effort": model.default_effort,
|
|
1038
|
+
"effort_label": model.effort_label,
|
|
1039
|
+
"context_tiers": [list(tier) for tier in model.context_tiers]}
|
|
1033
1040
|
for model in models]
|
|
1034
1041
|
|
|
1035
1042
|
def resolve_skill_slug(self, label: str) -> str:
|
|
@@ -1781,6 +1788,7 @@ class AdminService:
|
|
|
1781
1788
|
"description": str(frontmatter.get("description", "")),
|
|
1782
1789
|
"model": str(frontmatter.get("model", "") or ""),
|
|
1783
1790
|
"effort": str(frontmatter.get("effort", "") or ""),
|
|
1791
|
+
"context_tier": str(frontmatter.get("x-codee-context-tier", "") or ""),
|
|
1784
1792
|
"agent": _agent_code(frontmatter.get("x-codee-agent", "")),
|
|
1785
1793
|
"type": infer_skill_type(frontmatter),
|
|
1786
1794
|
"cron": str(frontmatter.get("x-codee-cron", frontmatter.get("cron", "0 0 * * *"))),
|
|
@@ -1824,9 +1832,10 @@ class AdminService:
|
|
|
1824
1832
|
"name": name,
|
|
1825
1833
|
"description": skill["description"],
|
|
1826
1834
|
}
|
|
1827
|
-
#
|
|
1828
|
-
#
|
|
1829
|
-
#
|
|
1835
|
+
# These are left out entirely when unset, so the skill keeps running on
|
|
1836
|
+
# the default agent, whatever model that agent defaults to, that
|
|
1837
|
+
# model's own effort and its default context window, rather than on an
|
|
1838
|
+
# empty value.
|
|
1830
1839
|
agent = skill.get("agent", "").strip()
|
|
1831
1840
|
if agent:
|
|
1832
1841
|
if resolve_agent_code(agent) is None:
|
|
@@ -1838,6 +1847,9 @@ class AdminService:
|
|
|
1838
1847
|
effort = skill.get("effort", "").strip()
|
|
1839
1848
|
if effort:
|
|
1840
1849
|
frontmatter["effort"] = effort
|
|
1850
|
+
context_tier = skill.get("context_tier", "").strip()
|
|
1851
|
+
if context_tier and context_tier != "default":
|
|
1852
|
+
frontmatter["x-codee-context-tier"] = context_tier
|
|
1841
1853
|
skill_type = skill["type"]
|
|
1842
1854
|
if skill_type == "slash command":
|
|
1843
1855
|
frontmatter["disable-model-invocation"] = True
|
codee/executor.py
CHANGED
|
@@ -292,12 +292,14 @@ def _pull_latest_code() -> bool:
|
|
|
292
292
|
|
|
293
293
|
|
|
294
294
|
def _run_agent(user_message: str, session_id: str, model: str = "",
|
|
295
|
-
agent_code: str = "", label: str = "", effort: str = ""
|
|
295
|
+
agent_code: str = "", label: str = "", effort: str = "",
|
|
296
|
+
context_tier: str = "") -> str:
|
|
296
297
|
"""Run the skill's coding agent and return its response text.
|
|
297
298
|
|
|
298
299
|
``model`` comes from the triggering skill's ``model:`` frontmatter; agents
|
|
299
300
|
that can't be told which model to use ignore it. ``effort`` comes from its
|
|
300
|
-
``effort:`` frontmatter the same way
|
|
301
|
+
``effort:`` frontmatter the same way, and ``context_tier`` from its
|
|
302
|
+
``x-codee-context-tier:``. ``agent_code`` comes from
|
|
301
303
|
its ``x-codee-agent:`` frontmatter and picks which agent runs at all, empty
|
|
302
304
|
for the default one. Wraps the agent run in job tracking; the agent itself
|
|
303
305
|
raises on any failure so callers can retry.
|
|
@@ -311,8 +313,8 @@ def _run_agent(user_message: str, session_id: str, model: str = "",
|
|
|
311
313
|
agent=agent.DISPLAY_NAME,
|
|
312
314
|
model=model, main_context=context)
|
|
313
315
|
log.debug("job %s started: session=%s message=%r model=%r effort=%r "
|
|
314
|
-
"agent=%s", job_id, session_id, user_message,
|
|
315
|
-
agent.describe())
|
|
316
|
+
"context_tier=%r agent=%s", job_id, session_id, user_message,
|
|
317
|
+
model, effort, context_tier, agent.describe())
|
|
316
318
|
|
|
317
319
|
def opened(agent_session_id: str) -> None:
|
|
318
320
|
"""Record the session the agent actually opened, if it isn't ours.
|
|
@@ -330,7 +332,8 @@ def _run_agent(user_message: str, session_id: str, model: str = "",
|
|
|
330
332
|
|
|
331
333
|
_job_scope.job_id = job_id
|
|
332
334
|
try:
|
|
333
|
-
return agent.run(user_message, session_id, model, opened, effort
|
|
335
|
+
return agent.run(user_message, session_id, model, opened, effort,
|
|
336
|
+
context_tier)
|
|
334
337
|
except Exception:
|
|
335
338
|
# The agent exits however SIGTERM makes it exit, usually as a failure.
|
|
336
339
|
# Asked for from the dashboard, that is a kill and not worth a retry.
|
|
@@ -352,7 +355,7 @@ def _run_agent(user_message: str, session_id: str, model: str = "",
|
|
|
352
355
|
|
|
353
356
|
def _run_task(task_id: str, message: str, session_id: str, skill_name: str,
|
|
354
357
|
model: str = "", agent_code: str = "", label: str = "",
|
|
355
|
-
effort: str = "") -> None:
|
|
358
|
+
effort: str = "", context_tier: str = "") -> None:
|
|
356
359
|
"""Pool worker: run one task's coding agent, then release its in-flight slot.
|
|
357
360
|
|
|
358
361
|
Logs the outcome to the runs table like the cron/email/sqs triggers do, so
|
|
@@ -368,7 +371,7 @@ def _run_task(task_id: str, message: str, session_id: str, skill_name: str,
|
|
|
368
371
|
shown = label or message
|
|
369
372
|
try:
|
|
370
373
|
response = _run_agent(message, session_id, model, agent_code, label,
|
|
371
|
-
effort)
|
|
374
|
+
effort, context_tier)
|
|
372
375
|
log.info("Agent response for %s (%d chars): %s",
|
|
373
376
|
task_id, len(response), response)
|
|
374
377
|
runs_db.record_run(skill_name, "issue", session_id, "succeeded",
|
|
@@ -399,7 +402,7 @@ def _run_task(task_id: str, message: str, session_id: str, skill_name: str,
|
|
|
399
402
|
|
|
400
403
|
def _submit_task(task_id: str, message: str, session_id: str, skill_name: str,
|
|
401
404
|
model: str = "", agent_code: str = "", label: str = "",
|
|
402
|
-
effort: str = "") -> bool:
|
|
405
|
+
effort: str = "", context_tier: str = "") -> bool:
|
|
403
406
|
"""Start a task's agent unless one is already in flight or we're at the cap.
|
|
404
407
|
|
|
405
408
|
Returns True if launched, False if skipped — as a duplicate, or because
|
|
@@ -426,7 +429,7 @@ def _submit_task(task_id: str, message: str, session_id: str, skill_name: str,
|
|
|
426
429
|
# killing it mid-run, which is what the thread pool used to give us.
|
|
427
430
|
threading.Thread(target=_run_task, name=f"task-agent-{task_id}",
|
|
428
431
|
args=(task_id, message, session_id, skill_name, model,
|
|
429
|
-
agent_code, label, effort)).start()
|
|
432
|
+
agent_code, label, effort, context_tier)).start()
|
|
430
433
|
log.info("Started an agent for %s (%d running, max %d).",
|
|
431
434
|
task_id, depth, limit)
|
|
432
435
|
return True
|
|
@@ -528,7 +531,8 @@ def run_once() -> None:
|
|
|
528
531
|
task_id, status, issue_type, summary, session_id)
|
|
529
532
|
|
|
530
533
|
_submit_task(task_id, message, session_id, skill.name,
|
|
531
|
-
skill.model, skill.agent, label, skill.effort
|
|
534
|
+
skill.model, skill.agent, label, skill.effort,
|
|
535
|
+
skill.context_tier)
|
|
532
536
|
|
|
533
537
|
|
|
534
538
|
def main() -> None:
|
|
@@ -172,7 +172,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
172
172
|
calls = []
|
|
173
173
|
|
|
174
174
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
175
|
-
agent: str = "", effort: str = ""
|
|
175
|
+
agent: str = "", effort: str = "",
|
|
176
|
+
context_tier: str = "") -> str:
|
|
176
177
|
calls.append((model, agent))
|
|
177
178
|
return "done"
|
|
178
179
|
|
|
@@ -204,7 +205,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
204
205
|
calls = []
|
|
205
206
|
|
|
206
207
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
207
|
-
agent: str = "", effort: str = ""
|
|
208
|
+
agent: str = "", effort: str = "",
|
|
209
|
+
context_tier: str = "") -> str:
|
|
208
210
|
calls.append((message, session_id))
|
|
209
211
|
return "done"
|
|
210
212
|
|
|
@@ -239,7 +241,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
239
241
|
calls = []
|
|
240
242
|
|
|
241
243
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
242
|
-
agent: str = "", effort: str = ""
|
|
244
|
+
agent: str = "", effort: str = "",
|
|
245
|
+
context_tier: str = "") -> str:
|
|
243
246
|
calls.append(session_id)
|
|
244
247
|
if len(calls) == 1:
|
|
245
248
|
raise RuntimeError("over limit")
|
|
@@ -275,7 +278,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
275
278
|
calls = []
|
|
276
279
|
|
|
277
280
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
278
|
-
agent: str = "", effort: str = ""
|
|
281
|
+
agent: str = "", effort: str = "",
|
|
282
|
+
context_tier: str = "") -> str:
|
|
279
283
|
calls.append(session_id)
|
|
280
284
|
raise runs_db.JobKilled()
|
|
281
285
|
|
|
@@ -321,7 +325,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
321
325
|
calls = []
|
|
322
326
|
|
|
323
327
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
324
|
-
agent: str = "", effort: str = ""
|
|
328
|
+
agent: str = "", effort: str = "",
|
|
329
|
+
context_tier: str = "") -> str:
|
|
325
330
|
calls.append((message, session_id))
|
|
326
331
|
return "done"
|
|
327
332
|
|
|
@@ -379,7 +384,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
379
384
|
calls = []
|
|
380
385
|
|
|
381
386
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
382
|
-
agent: str = "", effort: str = ""
|
|
387
|
+
agent: str = "", effort: str = "",
|
|
388
|
+
context_tier: str = "") -> str:
|
|
383
389
|
calls.append((message, session_id))
|
|
384
390
|
return "done"
|
|
385
391
|
|
|
@@ -415,7 +421,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
415
421
|
calls = []
|
|
416
422
|
|
|
417
423
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
418
|
-
agent: str = "", effort: str = ""
|
|
424
|
+
agent: str = "", effort: str = "",
|
|
425
|
+
context_tier: str = "") -> str:
|
|
419
426
|
calls.append(session_id)
|
|
420
427
|
return "done"
|
|
421
428
|
|
|
@@ -456,7 +463,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
456
463
|
calls = []
|
|
457
464
|
|
|
458
465
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
459
|
-
agent: str = "", effort: str = ""
|
|
466
|
+
agent: str = "", effort: str = "",
|
|
467
|
+
context_tier: str = "") -> str:
|
|
460
468
|
calls.append(session_id)
|
|
461
469
|
raise RuntimeError("over limit")
|
|
462
470
|
|
|
@@ -488,15 +496,18 @@ class CronSkillTests(unittest.TestCase):
|
|
|
488
496
|
calls = []
|
|
489
497
|
|
|
490
498
|
def run_claude(message: str, session_id: str, model: str = "",
|
|
491
|
-
agent: str = "", effort: str = ""
|
|
492
|
-
|
|
499
|
+
agent: str = "", effort: str = "",
|
|
500
|
+
context_tier: str = "") -> str:
|
|
501
|
+
calls.append((model, effort, context_tier))
|
|
493
502
|
return "done"
|
|
494
503
|
|
|
495
504
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
496
505
|
root = Path(temp_dir)
|
|
497
506
|
skills_dir = root / "skills"
|
|
498
507
|
for slug, model_line in (("with-model", "model: claude-opus-5\n"
|
|
499
|
-
"effort: high\n"
|
|
508
|
+
"effort: high\n"
|
|
509
|
+
"x-codee-context-tier: "
|
|
510
|
+
"long_context\n"),
|
|
500
511
|
("without-model", "")):
|
|
501
512
|
skill_dir = skills_dir / slug
|
|
502
513
|
skill_dir.mkdir(parents=True)
|
|
@@ -516,7 +527,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
516
527
|
main_context=_ctx(root))
|
|
517
528
|
|
|
518
529
|
# Sorted by directory name, so the skill declaring a model comes first.
|
|
519
|
-
self.assertEqual(calls, [("claude-opus-5", "high"
|
|
530
|
+
self.assertEqual(calls, [("claude-opus-5", "high", "long_context"),
|
|
531
|
+
("", "", "")])
|
|
520
532
|
|
|
521
533
|
def test_reconcile_runs_one_aws_sqs_message_per_tick(self):
|
|
522
534
|
calls = []
|
|
@@ -528,7 +540,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
528
540
|
sqs_source = FakeSqsMessageSource([message])
|
|
529
541
|
|
|
530
542
|
def run_claude(user_message: str, session_id: str, model: str = "",
|
|
531
|
-
agent: str = "", effort: str = ""
|
|
543
|
+
agent: str = "", effort: str = "",
|
|
544
|
+
context_tier: str = "") -> str:
|
|
532
545
|
calls.append((user_message, session_id))
|
|
533
546
|
return "done"
|
|
534
547
|
|
|
@@ -568,7 +581,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
568
581
|
sqs_source = FakeSqsMessageSource([message])
|
|
569
582
|
|
|
570
583
|
def run_claude(user_message: str, session_id: str, model: str = "",
|
|
571
|
-
agent: str = "", effort: str = ""
|
|
584
|
+
agent: str = "", effort: str = "",
|
|
585
|
+
context_tier: str = "") -> str:
|
|
572
586
|
raise runs_db.JobKilled()
|
|
573
587
|
|
|
574
588
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
@@ -599,7 +613,8 @@ class CronSkillTests(unittest.TestCase):
|
|
|
599
613
|
|
|
600
614
|
def test_reconcile_survives_unconfigured_aws_client(self):
|
|
601
615
|
def run_claude(user_message: str, session_id: str, model: str = "",
|
|
602
|
-
agent: str = "", effort: str = ""
|
|
616
|
+
agent: str = "", effort: str = "",
|
|
617
|
+
context_tier: str = "") -> str:
|
|
603
618
|
raise AssertionError("should not run without an SQS client")
|
|
604
619
|
|
|
605
620
|
with tempfile.TemporaryDirectory() as temp_dir:
|
|
@@ -70,7 +70,8 @@ class EmailTriggerTests(unittest.TestCase):
|
|
|
70
70
|
patch.object(module.runs_db, "record_run").start()
|
|
71
71
|
self.addCleanup(patch.stopall)
|
|
72
72
|
|
|
73
|
-
def run_claude(self, prompt, session_id, model, agent, effort=""
|
|
73
|
+
def run_claude(self, prompt, session_id, model, agent, effort="",
|
|
74
|
+
context_tier=""):
|
|
74
75
|
self.prompts.append(prompt)
|
|
75
76
|
return "ok"
|
|
76
77
|
|
|
@@ -24,6 +24,7 @@ class AwsSqsTriggeredSkill:
|
|
|
24
24
|
model: str
|
|
25
25
|
agent: str = ""
|
|
26
26
|
effort: str = ""
|
|
27
|
+
context_tier: str = ""
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
@dataclass(frozen=True)
|
|
@@ -76,7 +77,8 @@ def trigger_aws_sqs_skills(
|
|
|
76
77
|
prompt = render_aws_sqs_prompt(skill.body, message.content)
|
|
77
78
|
try:
|
|
78
79
|
response = run_claude(prompt, session_id, skill.model, skill.agent,
|
|
79
|
-
effort=skill.effort
|
|
80
|
+
effort=skill.effort,
|
|
81
|
+
context_tier=skill.context_tier)
|
|
80
82
|
print(
|
|
81
83
|
f"[aws_sqs_skills] Claude response for {skill.name} ({len(response)} chars)")
|
|
82
84
|
sqs_message_source.delete(message)
|
|
@@ -144,6 +146,7 @@ def find_aws_sqs_triggered_skills(skills_dir: Path = SKILLS_DIR) -> list[AwsSqsT
|
|
|
144
146
|
model=metadata.get("model", "").strip(),
|
|
145
147
|
agent=metadata.get("x-codee-agent", "").strip(),
|
|
146
148
|
effort=metadata.get("effort", "").strip(),
|
|
149
|
+
context_tier=metadata.get("x-codee-context-tier", "").strip(),
|
|
147
150
|
)
|
|
148
151
|
)
|
|
149
152
|
return skills
|