Skip to content

Commit db07b1f

Browse files
authored
Merge pull request #30 from GitHubSecurityLab/add_model_config
add model config
2 parents 213b161 + 7b2360f commit db07b1f

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

available_tools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self, yamls: dict):
2525
self.taskflows = {}
2626
self.prompts = {}
2727
self.toolboxes = {}
28+
self.model_config = {}
2829

2930
# Iterate through all the yaml files and divide them into categories.
3031
# Each file should contain a header like this:
@@ -49,6 +50,8 @@ def __init__(self, yamls: dict):
4950
add_yaml_to_dict(self.prompts, filekey, yaml)
5051
elif filetype == 'toolbox':
5152
add_yaml_to_dict(self.toolboxes, filekey, yaml)
53+
elif filetype == 'model_config':
54+
add_yaml_to_dict(self.model_config, filekey, yaml)
5255
else:
5356
raise FileTypeException(str(filetype))
5457
except KeyError as err:

configs/model_config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
seclab-taskflow-agent:
2+
version: 1
3+
filetype: model_config
4+
filekey: GitHubSecurityLab/seclab-taskflow-agent/configs/model_config
5+
models:
6+
sonnet_default: claude-sonnet-4
7+
sonnet_latest: claude-sonnet-4.5
8+
gpt_default: gpt-4.1
9+
gpt_latest: gpt-5

main.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,16 @@ async def on_handoff_hook(
429429

430430
# optional global vars available for the taskflow tasks
431431
global_variables = taskflow.get('globals', {})
432+
model_config = taskflow.get('model_config', {})
433+
if model_config:
434+
model_dict = available_tools.model_config.get(model_config, {})
435+
if not model_dict:
436+
raise ValueError(f"No such model config: {model_config}")
437+
model_dict = model_dict.get('models', {})
438+
if model_dict:
439+
if not isinstance(model_dict, dict):
440+
raise ValueError(f"Models section of the model_config file {model_config} must be a dictionary")
441+
model_keys = model_dict.keys()
432442

433443
for task in taskflow['taskflow']:
434444

@@ -448,7 +458,9 @@ async def on_handoff_hook(
448458
for k,v in reusable_taskflow['taskflow'][0]['task'].items():
449459
if k not in task_body:
450460
task_body[k] = v
451-
461+
model = task_body.get('model', DEFAULT_MODEL)
462+
if model in model_keys:
463+
model = model_dict[model]
452464
# parse our taskflow grammar
453465
name = task_body.get('name', 'taskflow') # placeholder, not used yet
454466
description = task_body.get('description', 'taskflow') # placeholder not used yet
@@ -465,7 +477,6 @@ async def on_handoff_hook(
465477
toolboxes_override = task_body.get('toolboxes', [])
466478
env = task_body.get('env', {})
467479
repeat_prompt = task_body.get('repeat_prompt', False)
468-
model = task_body.get('model', DEFAULT_MODEL)
469480
# this will set Agent 'stop_on_first_tool' tool use behavior, which prevents output back to llm
470481
exclude_from_context = task_body.get('exclude_from_context', False)
471482
# this allows you to run repeated prompts concurrently with a limit
@@ -600,6 +611,7 @@ async def _deploy_task_agents(resolved_agents, prompt):
600611
run_hooks=TaskRunHooks(
601612
on_tool_end=on_tool_end_hook,
602613
on_tool_start=on_tool_start_hook),
614+
model = model,
603615
agent_hooks=TaskAgentHooks(
604616
on_handoff=on_handoff_hook))
605617
return result
@@ -643,7 +655,8 @@ async def _deploy_task_agents(resolved_agents, prompt):
643655
YamlParser(cwd).get_yaml_dict((cwd/'personalities').rglob('*')) |
644656
YamlParser(cwd).get_yaml_dict((cwd/'taskflows').rglob('*')) |
645657
YamlParser(cwd).get_yaml_dict((cwd/'prompts').rglob('*')) |
646-
YamlParser(cwd).get_yaml_dict((cwd/'toolboxes').rglob('*')))
658+
YamlParser(cwd).get_yaml_dict((cwd/'toolboxes').rglob('*')) |
659+
YamlParser(cwd).get_yaml_dict((cwd/'configs').rglob('*')))
647660

648661
p, t, l, user_prompt, help_msg = parse_prompt_args(available_tools)
649662

taskflows/CVE-2023-2283/CVE-2023-2283.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ seclab-taskflow-agent:
33
filetype: taskflow
44
filekey: GitHubSecurityLab/seclab-taskflow-agent/taskflows/CVE-2023-2283/CVE-2023-2283
55

6+
model_config: GitHubSecurityLab/seclab-taskflow-agent/configs/model_config
7+
68
taskflow:
79
- task:
810
must_complete: true
@@ -14,7 +16,7 @@ taskflow:
1416
toolboxes:
1517
- GitHubSecurityLab/seclab-taskflow-agent/toolboxes/memcache
1618
- task:
17-
model: gpt-4.1
19+
model: gpt_latest
1820
must_complete: false
1921
agents:
2022
- GitHubSecurityLab/seclab-taskflow-agent/personalities/c_auditer

0 commit comments

Comments
 (0)