summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/docs/customization.md39
1 files changed, 39 insertions, 0 deletions
diff --git a/docs/docs/customization.md b/docs/docs/customization.md
index 22fcbb3d..a09c4ac5 100644
--- a/docs/docs/customization.md
+++ b/docs/docs/customization.md
@@ -192,3 +192,42 @@ config = ContinueConfig(
]
)
```
+
+## Custom Policies
+
+Policies can be used to deeply change the behavior of Continue, or to build agents that take longer sequences of actions on their own. The [`DefaultPolicy`](https://github.com/continuedev/continue/blob/main/continuedev/src/continuedev/plugins/policies/default.py) handles the parsing of slash commands, and otherwise always chooses the `SimpleChatStep`, but you could customize by for example always taking a "review" step after editing code. To do so, create a new `Policy` subclass that implements the `next` method:
+
+```python
+class ReviewEditsPolicy(Policy):
+
+ default_step: Step = SimpleChatStep()
+
+ def next(self, config: ContinueConfig, history: History) -> Step:
+ # Get the last step
+ last_step = history.get_current()
+
+ # If it edited code, then review the changes
+ if isinstance(last_step, EditHighlightedCodeStep):
+ return ReviewStep() # Not implemented
+
+ # Otherwise, choose between EditHighlightedCodeStep and SimpleChatStep based on slash command
+ if observation is not None and isinstance(last_step.observation, UserInputObservation):
+ if user_input.startswith("/edit"):
+ return EditHighlightedCodeStep(user_input=user_input[5:])
+ else:
+ return SimpleChatStep()
+
+ return self.default_step.copy()
+
+ # Don't do anything until the user enters something else
+ return None
+```
+
+Then, in `~/.continue/config.py`, override the default policy:
+
+```python
+config=ContinueConfig(
+ ...
+ policy_override=ReviewEditsPolicy()
+)
+```